public void DownloadTheNewlyUploadedDocument(string srcPath, string tgtPath) { int chunkCounter = 0; Byte[] fileData = new Byte[64000]; GINIX_EDMServices.EdmServicesForKit uploader = new GINIX_EDMServices.EdmServicesForKit(); do { try { string locationCode = ConfigurationManager.AppSettings["print_server_location"]; fileData = uploader.FetchFileChunk(srcPath, false, null, locationCode, chunkCounter); if (fileData != null) { SaveDocument(fileData, chunkCounter, tgtPath); chunkCounter++; } else { LogWriter.WriteLog("counter:" + chunkCounter++); break; } } catch (Exception exp) { break; } }while (true); }
/// <summary> /// Download files from app. server for printing. /// </summary> /// <param name="files"></param> /// <param name="findLatest">true:If file exists in both kitserver and app server then get the latest one. false: directly download file from app server.</param> private void DownLoadFiles(List <string> files, bool findLatest, DateTime?lastModifiedDTime) { GINIX_EDMServices.EdmServicesForKit uploader = new GINIX_EDMServices.EdmServicesForKit(); //EdmServices.EdmServicesForKit uploader = new EdmServices.EdmServicesForKit(); string locationCode = ConfigurationManager.AppSettings["print_server_location"]; foreach (string file in files) { DownloadSingleFile(file, findLatest, lastModifiedDTime, locationCode, ref uploader); //string msg = uploader.UploadDocument(file, findLatest, lastModifiedDTime, locationCode); } }
//[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)] public string UploadDocument(string filePath, string appServerSubPath) { GINIX_EDMServices.EdmServicesForKit uploader = new GINIX_EDMServices.EdmServicesForKit(); //EdmServices.EdmServicesForKit uploader = new EdmServices.EdmServicesForKit(); filePath = filePath.Replace("@@", "\\").Replace("/", "\\"); appServerSubPath = appServerSubPath.Replace("@@", "\\").Replace("/", "\\"); string fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1); LogWriter.WriteLog(filePath + "@@@@@@@@@" + appServerSubPath); System.IO.FileStream fileStream = new FileStream(filePath, FileMode.Open); string message = string.Empty; string fb = string.Empty; byte[] fileBuffer = null; for (int counter = 0; ; counter++) { try { fileBuffer = GiveFileChunk(counter, ref fileStream); if (fileBuffer == null) { break; } if (counter == 0) { string xx = uploader.SaveDocument(fileBuffer, counter, true, appServerSubPath); continue; } string xxg = uploader.SaveDocument(fileBuffer, counter, false, appServerSubPath); } catch (Exception ex) { message = "error"; break; } } fileStream.Close(); System.IO.File.Delete(filePath); return(message); }
public void GetFullXML(string filePath) { this.baseUrl = baseUrl; string[] dirArr = filePath.Split('|'); string fullXmlTmpDirectoryName = dirArr[dirArr.Length - 2]; filePath = filePath.Replace('|', Path.DirectorySeparatorChar); GINIX_EDMServices.EdmServicesForKit uploader = new GINIX_EDMServices.EdmServicesForKit(); string xmlString = uploader.GetFullXML(filePath); XElement xElmt = XElement.Parse(xmlString); var jobs = from file in xElmt.Descendants("Job") select file; List <string> stuklists = new List <string>(); List <string> otherFiles = new List <string>(); string fileType = ""; foreach (var job in jobs) { fileType = job.Descendants("Type").Single().Value.ToUpper(); if (fileType.Equals("STUKLIJST") || fileType.Equals("KOPBLAD")) { stuklists.Add(job.Descendants("File").Single().Value); } else { otherFiles.Add(job.Descendants("File").Single().Value); } } DownLoadFiles(stuklists, false, null); DownloadFilesIfNotExists(otherFiles); string fullXmlPath = ConfigurationManager.AppSettings["fullXml_path"].ToString() + fullXmlTmpDirectoryName; Directory.CreateDirectory(fullXmlPath); XmlDocument xDoc = new XmlDocument(); xDoc.InnerXml = xmlString; xDoc.Save(fullXmlPath + Path.DirectorySeparatorChar + "FullXml.xml"); }
private string DoSecurityCheck(string userId, string password, string appl, string baseUrl, string kitServerUrl, ref string roleName, ref string rolePass) { string returnUrl = string.Empty; IsValidLANUser(userId, password, appl, ref roleName, ref rolePass); if (!roleName.Equals(string.Empty) && !rolePass.Equals(string.Empty)) { string print_server_location = ConfigurationManager.AppSettings["print_server_location"]; string docSharePath = ConfigurationManager.AppSettings["docSharedPath"]; ConfigurationManager.AppSettings["GINIX_EDMServices.EdmServicesForKit"] = baseUrl + "/EdmServicesForKit.asmx"; GINIX_EDMServices.EdmServicesForKit cs = new GINIX_EDMServices.EdmServicesForKit(); try { string securityId = cs.ValidateUserAndGetSecurityId(userId, roleName, rolePass, print_server_location, kitServerUrl, docSharePath); if (!securityId.Equals("-1")) { returnUrl = baseUrl + "/Default.aspx?sid=" + securityId; } else { returnUrl = "invalid"; } } catch (Exception ex) { returnUrl = "invalid"; } } else { returnUrl = "invalid"; } return(returnUrl); }
void DownloadSingleFile(string file, bool findLatest, DateTime?lastModifiedDTime, string locationCode, ref GINIX_EDMServices.EdmServicesForKit uploader) { int chunkCounter = 0; Byte[] fileData = new Byte[64000]; do { try { fileData = uploader.FetchFileChunk(file, findLatest, lastModifiedDTime, locationCode, chunkCounter); if (fileData != null) { SaveDocument(fileData, chunkCounter, file); chunkCounter++; } else { break; } } catch (Exception exp) { break; } }while (true); }