javascript function:
function Archive_insert_Save_DB(saved_Doc_Extension) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
var datajsonparam = {
hidLibrary: $('#hidLibrary').prop('value'),
hidFormID: $("#hidFormID").prop('value'),
hidProfileID: "" + $("#hidProfileID").prop('value'),
hidDocID: $("#hidDocID").prop('value'),
hidDocName: $("#hidDocName").prop('value'),
hidIsVersion: $("#hidIsVersion").prop('value'),
hidDocComment: $("#hidDocComment").prop('value'),
hidFTPGuidName: $("#hidFTPGuidName").prop('value'),
hidUserID: $("#hidUserID").prop('value'),
HidMRTYPE: $("#HidMRTYPE").prop('value'),
hidDOC_DATE_EN: $("#hidDOC_DATE_EN").prop('value'),
hidDOC_DATE_AR: $("#hidDOC_DATE_AR").prop('value'),
saved_Doc_Extension: saved_Doc_Extension
};
$.ajax({
type: "POST",
url: "scan.aspx/Add_Document_DB_Operations",
data: JSON.stringify({ DocumentDetails: datajsonparam }),
//'{"hidLibrary" : "' + $("#hidFTPServer").prop('value') + '" ,"lang" : "' + lang + "hidLibrary" : "' + $("#hidFTPServer").prop('value') }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
$("#hidDocID").val(result.d);
alert("تمت عملية الأرشفة بنجاح - Archive Operation Succeeded");
window.opener.location.reload();
window.close();
},
error: function (x, e) { alert(x.responseText); }
});
}
--------------------------------------------------------------------
[WebMethod]
public static string Add_Document_DB_Operations(DocumentDetail DocumentDetails)
{
if (DocumentDetails.hidIsVersion.Length > 0)
{
//insert document in table doc_Versions
string doc_version_ID = archive_Class.Doc_Versions_INSERT(DocumentDetails.hidDocID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
//update main version to the new version inserted
archive_Class.Doc_Versions_Set_AS_Main_Doc(int.Parse(DocumentDetails.hidDocID), int.Parse(doc_version_ID));
//update main document in table profile_docs to the name of the new version file
archive_Class.Profile_Docs_UPDATE_Phisical_File_Name(int.Parse(DocumentDetails.hidDocID), DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
try
{
archive_Class.Archive_History_Insert(int.Parse(DocumentDetails.hidLibrary), int.Parse(DocumentDetails.hidFormID), int.Parse(DocumentDetails.hidProfileID), int.Parse(DocumentDetails.hidDocID), int.Parse(doc_version_ID),
Convert.ToInt32(ArchiveOperations.DocVersion_Add),
Convert.ToInt32(DocumentDetails.hidUserID), " تم عمل مسح ضوئي لوثيقة الإصدار رقم : " + doc_version_ID.ToString() + " عنوان الوثيقة : " + DocumentDetails.hidDocName);
}
catch (Exception ex)
{ Elmah.ErrorSignal.FromCurrentContext().Raise(ex); }
}
else
{
if (DocumentDetails.HidMRTYPE.Length > 0)
DocumentDetails.hidDocID = archive_Class.Profile_Docs_INSERT_MR(DocumentDetails.hidProfileID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID, DocumentDetails.HidMRTYPE, DocumentDetails.hidDOC_DATE_EN, DocumentDetails.hidDOC_DATE_AR);
else
//insert documents in db in table profile_Docs
DocumentDetails.hidDocID = archive_Class.Profile_Docs_INSERT(DocumentDetails.hidProfileID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
//insert new version for the document and make it as main doc version
archive_Class.Doc_Versions_INSERT(DocumentDetails.hidDocID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
//try
//{
archive_Class.Archive_History_Insert(int.Parse(DocumentDetails.hidLibrary), int.Parse(DocumentDetails.hidFormID), int.Parse(DocumentDetails.hidProfileID), int.Parse(DocumentDetails.hidDocID), 0,
Convert.ToInt32(ArchiveOperations.Document_Add),
Convert.ToInt32(DocumentDetails.hidUserID), " تم عمل مسح ضوئي للوثيقة رقم : " + DocumentDetails.hidDocID + " عنوان الوثيقة : " + DocumentDetails.hidDocName);
//}
//catch (Exception ex)
//{ Elmah.ErrorSignal.FromCurrentContext().Raise(ex); }
}
// _ArchiveClass.CreateArchiveFolders(DocumentDetails.hidLibrary, DocumentDetails.hidFormID, DocumentDetails.hidProfileID, DocumentDetails.hidDocID);
//ftp "/" + hidLibraryID.Value + "/" + hidFormID.Value + "/" + hidProfileID.Value + "/" + row.Cells[0].Text + "/" + phisicalname);
Doc_Server doc_srv = new Doc_Server(int.Parse(DocumentDetails.hidDocID.ToString()));
string controlSavedPath="/" + DocumentDetails.hidLibrary + "/" + DocumentDetails.hidFormID + "/" + DocumentDetails.hidProfileID + "/" + DocumentDetails.hidFTPGuidName + ".pdf";
doc_srv.ftpRelativeFilePath = "/" + DocumentDetails.hidLibrary + "/" + DocumentDetails.hidFormID + "/" + DocumentDetails.hidProfileID + "/" + DocumentDetails.hidDocID + "/";
FTP_Handler.CreateFTP_Directories(doc_srv);
FTP_Handler.ftp_Move_File_afterSave(doc_srv, controlSavedPath, doc_srv.ftpRelativeFilePath, DocumentDetails.hidFTPGuidName + ".pdf");
//}
//catch (Exception ex)
//{
// Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
// var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
// string script = "alert('" + ex.Message + "');";
// Page.ClientScript.RegisterStartupScript(this.GetType(), "sctipKey", script, true);
//}
return DocumentDetails.hidDocID;
}
}
---------------------------------------------------------------------------
Class
public class DocumentDetail
{
public string hidLibrary { get; set; }
public string hidFormID { get; set; }
public string hidProfileID { get; set; }
public string hidDocID { get; set; }
public string hidDocName { get; set; }
public string hidIsVersion { get; set; }
public string hidDocComment { get; set; }
public string hidFTPGuidName { get; set; }
public string hidUserID { get; set; }
public string HidMRTYPE { get; set; }
public string hidDOC_DATE_EN { get; set; }
public string hidDOC_DATE_AR { get; set; }
public string hidVersionID { get; set; }
public string saved_Doc_Extension { get; set; }
}
}
function Archive_insert_Save_DB(saved_Doc_Extension) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
var datajsonparam = {
hidLibrary: $('#hidLibrary').prop('value'),
hidFormID: $("#hidFormID").prop('value'),
hidProfileID: "" + $("#hidProfileID").prop('value'),
hidDocID: $("#hidDocID").prop('value'),
hidDocName: $("#hidDocName").prop('value'),
hidIsVersion: $("#hidIsVersion").prop('value'),
hidDocComment: $("#hidDocComment").prop('value'),
hidFTPGuidName: $("#hidFTPGuidName").prop('value'),
hidUserID: $("#hidUserID").prop('value'),
HidMRTYPE: $("#HidMRTYPE").prop('value'),
hidDOC_DATE_EN: $("#hidDOC_DATE_EN").prop('value'),
hidDOC_DATE_AR: $("#hidDOC_DATE_AR").prop('value'),
saved_Doc_Extension: saved_Doc_Extension
};
$.ajax({
type: "POST",
url: "scan.aspx/Add_Document_DB_Operations",
data: JSON.stringify({ DocumentDetails: datajsonparam }),
//'{"hidLibrary" : "' + $("#hidFTPServer").prop('value') + '" ,"lang" : "' + lang + "hidLibrary" : "' + $("#hidFTPServer").prop('value') }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
$("#hidDocID").val(result.d);
alert("تمت عملية الأرشفة بنجاح - Archive Operation Succeeded");
window.opener.location.reload();
window.close();
},
error: function (x, e) { alert(x.responseText); }
});
}
--------------------------------------------------------------------
[WebMethod]
public static string Add_Document_DB_Operations(DocumentDetail DocumentDetails)
{
if (DocumentDetails.hidIsVersion.Length > 0)
{
//insert document in table doc_Versions
string doc_version_ID = archive_Class.Doc_Versions_INSERT(DocumentDetails.hidDocID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
//update main version to the new version inserted
archive_Class.Doc_Versions_Set_AS_Main_Doc(int.Parse(DocumentDetails.hidDocID), int.Parse(doc_version_ID));
//update main document in table profile_docs to the name of the new version file
archive_Class.Profile_Docs_UPDATE_Phisical_File_Name(int.Parse(DocumentDetails.hidDocID), DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
try
{
archive_Class.Archive_History_Insert(int.Parse(DocumentDetails.hidLibrary), int.Parse(DocumentDetails.hidFormID), int.Parse(DocumentDetails.hidProfileID), int.Parse(DocumentDetails.hidDocID), int.Parse(doc_version_ID),
Convert.ToInt32(ArchiveOperations.DocVersion_Add),
Convert.ToInt32(DocumentDetails.hidUserID), " تم عمل مسح ضوئي لوثيقة الإصدار رقم : " + doc_version_ID.ToString() + " عنوان الوثيقة : " + DocumentDetails.hidDocName);
}
catch (Exception ex)
{ Elmah.ErrorSignal.FromCurrentContext().Raise(ex); }
}
else
{
if (DocumentDetails.HidMRTYPE.Length > 0)
DocumentDetails.hidDocID = archive_Class.Profile_Docs_INSERT_MR(DocumentDetails.hidProfileID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID, DocumentDetails.HidMRTYPE, DocumentDetails.hidDOC_DATE_EN, DocumentDetails.hidDOC_DATE_AR);
else
//insert documents in db in table profile_Docs
DocumentDetails.hidDocID = archive_Class.Profile_Docs_INSERT(DocumentDetails.hidProfileID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
//insert new version for the document and make it as main doc version
archive_Class.Doc_Versions_INSERT(DocumentDetails.hidDocID, DocumentDetails.hidDocName, DocumentDetails.hidDocComment, DocumentDetails.hidFTPGuidName + DocumentDetails.saved_Doc_Extension, DocumentDetails.hidUserID);
//try
//{
archive_Class.Archive_History_Insert(int.Parse(DocumentDetails.hidLibrary), int.Parse(DocumentDetails.hidFormID), int.Parse(DocumentDetails.hidProfileID), int.Parse(DocumentDetails.hidDocID), 0,
Convert.ToInt32(ArchiveOperations.Document_Add),
Convert.ToInt32(DocumentDetails.hidUserID), " تم عمل مسح ضوئي للوثيقة رقم : " + DocumentDetails.hidDocID + " عنوان الوثيقة : " + DocumentDetails.hidDocName);
//}
//catch (Exception ex)
//{ Elmah.ErrorSignal.FromCurrentContext().Raise(ex); }
}
// _ArchiveClass.CreateArchiveFolders(DocumentDetails.hidLibrary, DocumentDetails.hidFormID, DocumentDetails.hidProfileID, DocumentDetails.hidDocID);
//ftp "/" + hidLibraryID.Value + "/" + hidFormID.Value + "/" + hidProfileID.Value + "/" + row.Cells[0].Text + "/" + phisicalname);
Doc_Server doc_srv = new Doc_Server(int.Parse(DocumentDetails.hidDocID.ToString()));
string controlSavedPath="/" + DocumentDetails.hidLibrary + "/" + DocumentDetails.hidFormID + "/" + DocumentDetails.hidProfileID + "/" + DocumentDetails.hidFTPGuidName + ".pdf";
doc_srv.ftpRelativeFilePath = "/" + DocumentDetails.hidLibrary + "/" + DocumentDetails.hidFormID + "/" + DocumentDetails.hidProfileID + "/" + DocumentDetails.hidDocID + "/";
FTP_Handler.CreateFTP_Directories(doc_srv);
FTP_Handler.ftp_Move_File_afterSave(doc_srv, controlSavedPath, doc_srv.ftpRelativeFilePath, DocumentDetails.hidFTPGuidName + ".pdf");
//}
//catch (Exception ex)
//{
// Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
// var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
// string script = "alert('" + ex.Message + "');";
// Page.ClientScript.RegisterStartupScript(this.GetType(), "sctipKey", script, true);
//}
return DocumentDetails.hidDocID;
}
}
---------------------------------------------------------------------------
Class
public class DocumentDetail
{
public string hidLibrary { get; set; }
public string hidFormID { get; set; }
public string hidProfileID { get; set; }
public string hidDocID { get; set; }
public string hidDocName { get; set; }
public string hidIsVersion { get; set; }
public string hidDocComment { get; set; }
public string hidFTPGuidName { get; set; }
public string hidUserID { get; set; }
public string HidMRTYPE { get; set; }
public string hidDOC_DATE_EN { get; set; }
public string hidDOC_DATE_AR { get; set; }
public string hidVersionID { get; set; }
public string saved_Doc_Extension { get; set; }
}
}
No comments:
Post a Comment