コード例 #1
0
 public bool AddFileObj(Luna.DataSync.Core.PROD_SS.fileEntity arg0)
 {
     Luna.DataSync.Core.PROD_SS.AddFileObj inValue = new Luna.DataSync.Core.PROD_SS.AddFileObj();
     inValue.arg0 = arg0;
     Luna.DataSync.Core.PROD_SS.AddFileObjResponse retVal = ((Luna.DataSync.Core.PROD_SS.StorageService)(this)).AddFileObj(inValue);
     return(retVal.@return);
 }
コード例 #2
0
 public AddFileObj(Luna.DataSync.Core.PROD_SS.fileEntity arg0)
 {
     this.arg0 = arg0;
 }
コード例 #3
0
 public RetriveFileObjResponse(Luna.DataSync.Core.PROD_SS.fileEntity @return)
 {
     this.@return = @return;
 }
コード例 #4
0
ファイル: DataSynchronizer.cs プロジェクト: radtek/ThomRe
        /*Sync file from storage service of .28 to storage service of production*/
        private string SyncFile(System.Data.DataTable sourceData, TableMapping tableMapping, ref int successFileNo, ref int failFileNo)
        {
            var imeClient  = new Luna.DataSync.Core.IME_SS.StorageServiceClient();
            var prodClient = new Luna.DataSync.Core.PROD_SS.StorageServiceClient();
            var tableName  = tableMapping.Source;

            var msg = new StringBuilder();

            msg.AppendFormat("File sync detail for table:{0} : \n<ol>", tableMapping.Destination);

            foreach (System.Data.DataRow dtRow in sourceData.Rows)
            {
                string path     = "";
                string fileName = "";
                string fileId   = "";

                var keyColumns = tableMapping.GetKeyColumnNames().ToList();
                fileId = keyColumns.Count == 1 ? dtRow[keyColumns.FirstOrDefault()].ToString() : keyColumns.Aggregate((i, j) => dtRow[i] + "_" + dtRow[j]);

                //ignore if there is no physical path
                //when tablename = INSTITUTIONINFO, phisicalpath = |Logo
                var realPath = tableMapping.Source == "INSTITUTIONINFO" ? "|Logo" : dtRow[tableMapping.PathColumn].ToString();
                if (string.IsNullOrEmpty(realPath))
                {
                    continue;
                }

                realPath = realPath.Replace(@"\", "/");

                var ext = "";
                if (tableName.Equals("FILEDETAIL") || tableName.Equals("INSTITUTIONINFO"))
                {
                    ext  = "." + dtRow[tableMapping.ExtColumn];
                    path = tableMapping.PathRoot + (realPath.IndexOf("|") != 0 ? String.Format("|{0}", realPath) : realPath);
                }
                else
                {
                    ext  = Path.GetExtension(realPath);
                    path = tableMapping.PathRoot + realPath.Substring(0, realPath.LastIndexOf("/")).Replace("/", "|");
                }

                fileName = fileId + ext;

                fileEntity obj = null;

                obj = imeClient.RetriveFileObj(path, fileName);
                if (obj.fileData == null)
                {
                    //var strException = string.Format("Can not retrive file(ID:{0},path{1},name:{2}) \n from {3} from source table: {4} \n ", fileId, path, fileName, imeClient.Endpoint.Address, tableMapping.Source);
                    //throw new Exception(strException);
                    msg.AppendFormat("<li>{0}:{1}{2} <span style=\"color:red;\">failed</span>.<br/>(Cannot retrive file from {3})</li>", fileId, path, fileName,
                                     imeClient.Endpoint.Address);
                    failFileNo++;
                    continue;
                }

                bool success;
                //try
                //{
                //    Luna.DataSync.Core.PROD_SS.fileEntity newObj = new Luna.DataSync.Core.PROD_SS.fileEntity { fileData = obj.fileData, fileName = fileName, path = path };
                //    success = prodClient.AddFileObj(newObj);
                //}
                //catch (Exception ex)
                //{
                //    throw new Exception(string.Format("Get exception when call storage service (write file)\n " +
                //                                            "fileId: {0} in destination table: {1} \n  {2} \n", fileId, tableMapping.Source, ex));
                //}

                var newObj = new Luna.DataSync.Core.PROD_SS.fileEntity {
                    fileData = obj.fileData, fileName = fileName, path = path
                };
                success = prodClient.AddFileObj(newObj);
                if (!success)
                {
                    //throw new Exception(string.Format("Can not save file(ID:{0},path{1},name:{2}) \n to {3} in destination table: {4}", fileId, path, fileName, imeClient.Endpoint.Address, tableMapping.Source));
                    msg.AppendFormat("<li>{0}:{1}{2} <span style=\"color:red;\">failed</span>.<br/>(Cannot save file to {3})</li>", fileId, path, fileName,
                                     prodClient.Endpoint.Address);
                    failFileNo++;
                    continue;
                }

                msg.AppendFormat("<li>{0}:{1}{2} sync <span style=\"color:green;\">succeed</span>.</li>", fileId, path, fileName);
                successFileNo++;
                //try
                //{
                //    if (!success)
                //    {
                //        if (tableName.Equals("FILEDETAIL"))
                //            dtRow["ISVALID"] = 0;
                //        else
                //            dtRow["ISSYNCED"] = 0;

                //        syncInfo += string.Format("{0}|{1}, fail \n", path, fileName);
                //    }

                //    sourceData.AcceptChanges();

                //}
                //catch (Exception ex)
                //{
                //    throw new Exception(string.Format("Get exception when update file sync status\n " +
                //                    "fileId: {0} \n destination table: {1} \n  {2} \n", fileId, tableMapping.Destination, ex));
                //}
            }
            msg.Append("</ol>");
            return(msg.ToString());
        }