Ejemplo n.º 1
0
        /// <summary>
        /// 接口错误处理
        /// </summary>
        /// <param name="queueData"></param>
        /// <param name="msg"></param>
        private void ErrorSync(I_FileSynQueue queueData, string msg)
        {
            queueData.SynState = SynState.Error.ToString();
            queueData.SynTime  = DateTime.Now;
            queueData.ErrorMsg = msg;
            if (string.IsNullOrEmpty(queueData.Response))
            {
                queueData.Response = string.Empty;
            }
            if (string.IsNullOrEmpty(queueData.ErrorMsg))
            {
                queueData.ErrorMsg = string.Empty;
            }
            if (string.IsNullOrEmpty(queueData.FsFileID))
            {
                queueData.FsFileID = string.Empty;
            }
            string sql = @" update I_FileSynQueue set SynTime = '{1}', Response='{2}',ErrorMsg='{3}' ,SynState='{4}' ,RequestUrl='{5}'
                ,FsFileID='{6}' where ID='{0}'";

            sql = string.Format(sql, queueData.ID.ToString(), queueData.SynTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
                                , queueData.Response.Replace("'", "''"), queueData.ErrorMsg.Replace("'", "''"), queueData.SynState.ToString()
                                , queueData.RequestUrl.Replace("'", "''"), queueData.FsFileID.Replace("'", "''"));
            this.SQLHelperInterface.ExecuteNonQuery(sql);
        }
Ejemplo n.º 2
0
        private void ExecuteInputDocument(I_FileSynQueue queueData, string md5, StringBuilder sb, long filesize)
        {
            var sql = string.Empty;

            var sourceData = JsonHelper.ToObject(queueData.RequestData);
            var param      = new InputDocumentRequestData();

            param.fileMd5       = md5;
            param.fileId        = sourceData.GetValue("ID");
            param.fileName      = sourceData.GetValue("Name");
            param.folderId      = sourceData.GetValue("InputID");
            param.fileSize      = filesize;
            param.fileExtension = GetFileExt(sourceData.GetValue("Files"));
            param.userId        = sourceData.GetValue("CreateUserID");
            var synUser = GlobalData.UserList.FirstOrDefault(a => a.ID == param.userId);

            if (synUser != null && !string.IsNullOrEmpty(synUser.SynID))
            {
                param.userId = synUser.SynID;
            }
            sql = @"
if exists(select 1 from I_DataSynQueue where SynType='{0}' and RelateID='{2}' and SynState ='" + SynState.New.ToString() + @"')
    update I_DataSynQueue set CreateTime = '{4}', RequestData='{5}',  RequestUrl='{6}' where SynType='{0}' and RelateID='{2}' and SynState ='" + SynState.New.ToString() + @"'
else
    insert into I_DataSynQueue(SynType,RelateTable,RelateID,RelateType,CreateTime,RequestData,RequestUrl,SynState) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','" + SynState.New.ToString() + "')";
            sql = string.Format(sql, SynType.Save.ToString(), "S_D_InputDocument", param.fileId, ""
                                , DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), JsonHelper.ToJson <InputDocumentRequestData>(param).Replace("'", "''"), this.BaseServerUrl + "file/add");
            sb.AppendLine(sql);
        }
Ejemplo n.º 3
0
        private void ExecuteUpload(I_FileSynQueue queueData, StringBuilder sb, long filesize)
        {
            var rtn      = JsonHelper.ToObject(queueData.Response);
            var errorStr = string.Empty;

            if (rtn.GetValue("success").ToLower() != "true")
            {
                if (!string.IsNullOrEmpty(rtn.GetValue("error")))
                {
                    errorStr = string.Format("error:{0}", rtn.GetValue("error"));
                }
                else
                {
                    errorStr = queueData.Response;
                }
            }

            var md5 = rtn.GetValue("md5");

            //业务处理
            switch (queueData.RelateTable)
            {
            case "S_D_InputDocument": ExecuteInputDocument(queueData, md5, sb, filesize); break;

            default: break;
            }
            queueData.SynTime = DateTime.Now;
        }
Ejemplo n.º 4
0
        private void ExecuteDownload(I_FileSynQueue queueData, StringBuilder interfaceSb)
        {
            StringBuilder projectSb = new StringBuilder();

            if (queueData.RelateTable == "S_P_MileStone_ProductDetail")
            {
                #region 获取提资数据
                var milestoneDetailSql = string.Format(" update S_P_MileStone_ProductDetail set FileID='{1}' where id='{0}'", queueData.RelateID, queueData.FsFileID.Replace("'", "''"));
                projectSb.AppendLine(milestoneDetailSql);

                if (queueData.RelateType.ToLower() == "plan")
                {
                    //同步绑定S_E_Product 的文件数据
                    var productAttrInfo = JsonHelper.ToObject(queueData.RequestData);
                    var signatured      = productAttrInfo.GetValue("Signatured");//是否签名,如果签名则md5 为签名的pdf文件
                    var sourceFileId    = productAttrInfo.GetValue("SourceFileId");
                    var ext             = productAttrInfo.GetValue("Extension");
                    var drawingNo       = productAttrInfo.GetValue("DrawingNo");
                    if (!string.IsNullOrEmpty(drawingNo))
                    {
                        var field = "MainFile";
                        if (ext.ToLower() == ".pdf")
                        {
                            if (signatured.ToLower() == "true")
                            {
                                field = "SignPdfFile";
                            }
                            else
                            {
                                field = "PdfFile";
                            }
                        }
                        var productSql = string.Format(@"
                            update S_E_Product set {0}='{1}' where swffile='{2}' and code='{3}'
                            update S_E_ProductVersion set {0}='{1}' where swffile='{2}' and code='{3}'", field, queueData.FsFileID.Replace("'", "''"), sourceFileId, drawingNo);
                        projectSb.AppendLine(productSql);
                    }
                }
                #endregion
            }
            else
            {
                //I_FlowAuditProduct、I_FlowChangeProduct、I_FlowSignProduct、I_FlowExchangeProduct四张流程表数据
                var interfaceSql = string.Format(" update {2} set FsFileID='{1}' where id='{0}'", queueData.RelateID, queueData.FsFileID.Replace("'", "''"), queueData.RelateTable);
                interfaceSb.AppendLine(interfaceSql);
                if (queueData.RelateTable == "I_FlowExchangeProduct")
                {
                    //计划内 同时更新S_P_MileStone_ProductDetail数据
                    var milestoneDetailSql = string.Format(" update S_P_MileStone_ProductDetail set FileID='{1}' where id='{0}'", queueData.RelateID, queueData.FsFileID.Replace("'", "''"));
                    projectSb.AppendLine(milestoneDetailSql);
                }
            }
            if (projectSb.Length > 0)
            {
                this.SQLHelpeProject.ExecuteNonQuery(projectSb.ToString());
            }
        }
Ejemplo n.º 5
0
        public void CreateDesignInputFileQueue()
        {
            var sourceSql = @"select doc.* from S_D_InputDocument doc
left join S_D_Input m  on m.ID = doc.InputID
left join S_I_ProjectInfo p on p.ID = m.ProjectInfoID 
where 1=1 ";

            var synProjectMode = ConfigurationManager.AppSettings["SynProjectMode"] != null ? ConfigurationManager.AppSettings["SynProjectMode"].ToString() : string.Empty;

            if (!string.IsNullOrEmpty(synProjectMode))
            {
                sourceSql += "and ModeCode in ('" + synProjectMode.Replace(",", "','") + "') ";
            }

            //取最近的同步记录时间,到当前时间的差异数据
            var synData     = this.SQLHelperInterface.ExecuteList <S_D_InputDocument>("select * from S_D_InputDocument where 1=1 ");
            var lastSynTime = synData.Max(a => a.SynTime);

            if (lastSynTime != null)
            {
                //判断同步增量数据 还是 所有数据
                var startDate = Convert.ToDateTime(lastSynTime).ToString();
                var endDate   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                sourceSql += " and doc.CreateDate >='" + startDate + "' and doc.CreateDate <='" + endDate + "'";
            }

            #region Add

            var saveSb   = new StringBuilder();
            var sourceDt = this.SQLHelpeProject.ExecuteDataTable(sourceSql);
            foreach (DataRow row in sourceDt.Rows)
            {
                var dic  = DataHelper.DataRowToDic(row);
                var ID   = dic.GetValue("ID");
                var fsID = dic.GetValue("Files");
                I_FileSynQueue.CreateUploadQueue(saveSb, fsID, JsonHelper.ToJson(dic), "S_D_InputDocument", ID, "");
            }
            if (saveSb.Length > 0)
            {
                this.SQLHelperInterface.ExecuteNonQuery(saveSb.ToString());
            }
            #endregion
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 接口正常返回处理
 /// </summary>
 /// <param name="queueData"></param>
 private void ComplateSync(I_FileSynQueue queueData, StringBuilder sb)
 {
     sb.AppendLine(@" delete from I_FileSynQueue where ID='" + queueData.ID.ToString() + "'");
     this.SQLHelperInterface.ExecuteNonQuery(sb.ToString());
 }