Example #1
0
        /// <summary>
        /// 新的上传采集数据到工管中心的接口
        /// </summary>
        protected void UploadCaiJiData(JZDocument doc, Sys_Module ModuleBase, Guid TestDataID, string MachineCode, int SeriaNumber, string TestData, string UserName, string RealTimeData, string TestRoomCode)
        {
            String lineAddress = "net.tcp://" + IPAddress + ":" + Port + "/TransferService.svc";

            CallRemoteServerMethod(lineAddress, "Yqun.BO.BusinessManager.dll", "UploadCaiJiData",
                                   new Object[] { doc, ModuleBase, TestDataID, MachineCode, SeriaNumber, TestData, UserName, RealTimeData, TestRoomCode });
        }
 /// <summary>
 /// 获取压力数据实例对象
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="moduleID"></param>
 /// <param name="stadiumID"></param>
 /// <param name="wtbh"></param>
 /// <param name="testRoomCode"></param>
 /// <param name="seriaNumber"></param>
 /// <param name="userName"></param>
 /// <param name="cells"></param>
 /// <param name="realTimeData"></param>
 /// <param name="machineBH"></param>
 /// <returns></returns>
 private EMCServiceReference.PressureData GetPressureDataModel(JZDocument doc, Guid moduleID, Guid stadiumID, String wtbh, String testRoomCode,
                                                               Int32 seriaNumber, String userName, List <JZTestCell> cells, String realTimeData, string machineBH)
 {
     EMCServiceReference.PressureData _PressureDataModel = new EMCServiceReference.PressureData();
     try
     {
         _PressureDataModel.FGuid  = System.Guid.NewGuid().ToString();
         _PressureDataModel.FIswjj = "0";
         _PressureDataModel.FKylz  = Convert.ToDouble(cells[0].Value.ToString());
         DataTable _dt = _StadiumHelper.GetStadiumByID(stadiumID);
         if (_dt != null && _dt.Rows.Count > 0)
         {
             string tempRealTimeData = GetYSLZ(realTimeData);
             _PressureDataModel.FLq       = int.Parse(_dt.Rows[0]["DateSpan"].ToString());
             _PressureDataModel.FOperator = userName;
             _PressureDataModel.FQddj     = _dt.Rows[0]["F_Added"].ToString();
             _PressureDataModel.FRtcode   = GetModuleEMCRTCode(moduleID);
             _PressureDataModel.FSbbh     = machineBH;
             _PressureDataModel.FSjbh     = _dt.Rows[0]["F_SJBH"].ToString();
             _PressureDataModel.FSjcc     = GetSJCCMethod(_dt.Rows[0]["F_SJBH"].ToString());
             _PressureDataModel.FSoftcom  = "北京金舟神创科技发展有限公司";
             _PressureDataModel.FSysj     = tempRealTimeData.Split('|')[0];
             _PressureDataModel.FVender   = "北京金舟神创科技发展有限公司";
             _PressureDataModel.FWtbh     = wtbh;
             _PressureDataModel.FYskylz   = tempRealTimeData.Split('|')[1];
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
     }
     return(_PressureDataModel);
 }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String id = Request.Params["ID"];
            if (!String.IsNullOrEmpty(id))
            {
                string SQL = "SELECT * FROM dbo.sys_document WHERE ID='" + id + "'";

                DataSet    ds  = DbHelperSQL.Query(SQL);
                string     str = ds.Tables[0].Rows[0]["Data"].ToString();
                JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(str);
                if (doc != null)
                {
                    try
                    {
                        string Temp = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "AI".RequestStr()).ToString();

                        Response.Write("<img src='data:image/gif;base64," + Temp + "'  />");
                    }
                    catch
                    {
                        Response.Write("<div style=\"width:400px;height:300px;line-height:300px; text-align:center;\">无图片或图片有误</div>");
                    }
                }
            }
        }
    }
Example #4
0
        public JZDocument GetDefaultDocument(Guid moduleID)
        {
            String sql = @"SELECT a.ID,b.SheetID,c.SheetData,c.Name FROM dbo.sys_module a
                    JOIN dbo.sys_module_sheet b ON a.ID = b.ModuleID
                    JOIN dbo.sys_sheet c ON b.SheetID = c.ID where a.ID='" + moduleID + "' order by b.SortIndex";

            JZDocument doc = new JZDocument();

            try
            {
                DataTable dt = GetDataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    doc.ID = Guid.Empty;
                    foreach (DataRow row in dt.Rows)
                    {
                        JZSheet sheet = new JZSheet();
                        sheet.ID    = new Guid(row["SheetID"].ToString());
                        sheet.Name  = row["Name"].ToString();
                        sheet.Cells = Newtonsoft.Json.JsonConvert.DeserializeObject <List <JZCell> >(row["SheetData"].ToString());
                        doc.Sheets.Add(sheet);
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
            }

            return(doc);
        }
Example #5
0
        /// <summary>
        /// 旧的上传到工管中心的接口
        /// </summary>
        protected void UploadLabDocBasic(JZDocument doc, Sys_Module ModuleBase, string UserName, string TestRoomCode)
        {
            String lineAddress = "net.tcp://" + IPAddress + ":" + Port + "/TransferService.svc";

            CallRemoteServerMethod(lineAddress, "Yqun.BO.BusinessManager.dll", "UploadLabDocBasic",
                                   new Object[] { doc, ModuleBase, UserName, TestRoomCode });
        }
Example #6
0
        public void SetColumnFromSelector(int row, int sheetColumn, int cellColumn)
        {
            if (DocumentCache == null)
            {
                DocumentCache = ModuleHelperClient.GetDefaultDocument(SelectionModuleID);

                if (SheetsCache == null && DocumentCache != null)
                {
                    SheetsCache = new SheetView[DocumentCache.Sheets.Count];
                    for (var i = 0; i < SheetsCache.Length; i++)
                    {
                        var xml   = ModuleHelperClient.GetSheetXMLByID(DocumentCache.Sheets[i].ID);
                        var sheet = Serializer.LoadObjectXml(typeof(SheetView), xml, "SheetView") as SheetView;
                        sheet.SheetName = DocumentCache.Sheets[i].Name;
                        SheetsCache[i]  = sheet;
                    }
                }
            }

            var selector = new CellSelector(CurrentModule.ID, "", Guid.Empty);

            selector.Preloading(SheetsCache, DocumentCache);

            if (DialogResult.OK == selector.ShowDialog())
            {
                TableStatistics.ActiveSheet.Cells[row, sheetColumn].Value = selector.SheetName;
                TableStatistics.ActiveSheet.Cells[row, sheetColumn].Tag   = selector.SheetID;
                TableStatistics.ActiveSheet.Cells[row, cellColumn].Value  = selector.CellName;
                TableStatistics.ActiveSheet.Cells[row, cellColumn].Tag    = selector.CellName;
            }
        }
Example #7
0
        /// <summary>
        /// 旧的上传到工管中心的接口
        /// </summary>
        protected bool UpdateToEMC(JZDocument doc, Guid moduleID, Guid stadiumID, String wtbh, String testRoomCode,
                                   Int32 seriaNumber, String userName, List <JZTestCell> cells, String realTimeData, string machineBH)
        {
            String lineAddress = "net.tcp://" + IPAddress + ":" + Port + "/TransferService.svc";
            bool   bSuccess    = bool.Parse(CallRemoteServerMethod(lineAddress, "Yqun.BO.BusinessManager.dll", "UpdateToEMC",
                                                                   new Object[] { doc, moduleID, stadiumID, wtbh, testRoomCode,
                                                                                  seriaNumber, userName, cells, realTimeData, machineBH }).ToString());

            return(bSuccess);
        }
Example #8
0
        private void Execute(object paremeter)
        {
            ThreadParameter p             = paremeter as ThreadParameter;
            JZDocument      document      = p.document;
            Sys_Module      module        = p.module;
            String          invalidString = "";

            if (module != null)
            {
                if (module.QualifySettings != null && module.QualifySettings.Count > 0)
                {
                    foreach (QualifySetting qs in module.QualifySettings)
                    {
                        Object obj = JZCommonHelper.GetCellValue(document, qs.SheetID, qs.CellName);
                        if (obj != null && obj.ToString() != "")
                        {
                            invalidString = obj.ToString().Trim(' ', '\r', '\n');
                            break;
                        }
                    }
                }
            }
            if (invalidString != "")
            {
                try
                {
                    String[] arr = invalidString.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length < 3)
                    {
                        logger.Error("无效的不合格短信内容,document的ID为" + document.ID + ";短信内容为:" + invalidString);
                        return;
                    }
                    Boolean    needSendSMS = false;
                    SMSManager smsManager  = new SMSManager();
                    if (!p.IsAdministrator)
                    {
                        needSendSMS = smsManager.NeedSendSMS(document.ID.ToString(), invalidString);
                        logger.Error(invalidString + "needsendsms=" + needSendSMS);
                    }

                    if (needSendSMS)
                    {
                        smsManager.SendSMS(document.ID.ToString(), invalidString, p.LineID, p.TestRoomCode, p.SegmentName, p.CompanyName, p.TestRoomName, p.LineName);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("更新合格字段IsQualified失败,原因是" + ex.Message);
                }
            }
            icm.SyncInvalidReport(document.ID, invalidString);
        }
Example #9
0
    public void RoomInfo()
    {
        string  Sql = "select data from sys_document where moduleid ='E77624E9-5654-4185-9A29-8229AAFDD68B' AND testroomcode='" + "RoomID".RequestStr() + "'";
        DataSet Ds  = GetDs(Sql);

        if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
        {
            doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(Ds.Tables[0].Rows[0][0].ToString());
        }
        else
        {
            doc = new JZDocument();
        }
    }
Example #10
0
        private void TableModules_SelectionChanged(object sender, FarPoint.Win.Spread.SelectionChangedEventArgs e)
        {
            DocumentCache     = null;
            SheetsCache       = null;
            SelectionModule   = null;
            NeedSynchronous   = false;
            SelectionModuleID = GetSelectionModuleID();

            if (Modules != null)
            {
                SelectionModule = Modules.Rows.Find(SelectionModuleID);
            }

            SetStatisticsTable();
        }
Example #11
0
        public bool ProcessExtension(JZDocument sheet, StatisticsModuleSetting map, List <StatisticsSetting> columns, DataRow document, Sys_Module module, Dictionary <string, Object> result)
        {
            var documentID = new Guid(Convert.ToString(document["ID"]));

            switch (map.StatisticsItemName)
            {
            case "报告日期":
                return(true);

            case "厂家名称":
                return(ProcessFactory(documentID, module, result, sheet));

            case "试验人员":
            case "设备厂家":
            case "设备型号":
            case "仪表型号":
                var device = CallLocalMethod(Uri, DLL, "PickOneAcquisition", new object[] { documentID }) as DataTable;
                if (device == null || device.Rows.Count == 0)
                {
                    Logger.Info("获取 " + map.StatisticsItemName + " 到空值");
                    return(true);
                }

                var userName    = Convert.ToString(device.Rows[0]["UserName"]);
                var machineCode = Convert.ToString(device.Rows[0]["MachineCode"]);

                var item = columns.Find(m => m.ItemName == map.StatisticsItemName);
                if (item == null)
                {
                    Logger.Info("在统计项中获取名为 " + map.StatisticsItemName + " 的项为空");
                    return(true);
                }

                switch (map.StatisticsItemName)
                {
                case "试验人员":
                    result[item.BindField] = userName;
                    break;

                default:
                    result[item.BindField] = machineCode;
                    break;
                }
                return(true);
            }

            return(false);
        }
Example #12
0
        public void Qualify(JZDocument document, Sys_Module module)
        {
            ThreadParameter p = new ThreadParameter();

            p.document        = document;
            p.module          = module;
            p.IsAdministrator = ApplicationContext.Current.IsAdministrator;

            p.LineID       = ApplicationContext.Current.InProject.Index;
            p.TestRoomCode = ApplicationContext.Current.InTestRoom.Code;
            p.SegmentName  = ApplicationContext.Current.InSegment.Description;
            p.CompanyName  = ApplicationContext.Current.InCompany.Description;
            p.TestRoomName = ApplicationContext.Current.InTestRoom.Description;
            p.LineName     = ApplicationContext.Current.InProject.Description;
            ThreadPool.QueueUserWorkItem(new WaitCallback(Execute), p);
        }
 /// <summary>
 /// 获取万能机数据实例对象
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="moduleID"></param>
 /// <param name="stadiumID"></param>
 /// <param name="wtbh"></param>
 /// <param name="testRoomCode"></param>
 /// <param name="seriaNumber"></param>
 /// <param name="userName"></param>
 /// <param name="cells"></param>
 /// <param name="realTimeData"></param>
 /// <param name="machineBH"></param>
 /// <returns></returns>
 private EMCServiceReference.UniversalData GetUniversalDataModel(JZDocument doc, Guid moduleID, Guid stadiumID, String wtbh, String testRoomCode,
                                                                 Int32 seriaNumber, String userName, List <JZTestCell> cells, String realTimeData, string machineBH)
 {
     EMCServiceReference.UniversalData _UniversalDataModel = new EMCServiceReference.UniversalData();
     try
     {
         DataTable _dt = _StadiumHelper.GetStadiumByID(stadiumID);
         if (_dt != null && _dt.Rows.Count > 0)
         {
             string tempRealTimeData = GetYSLZ(realTimeData);
             _UniversalDataModel.FArea = ((Math.Pow(Convert.ToDouble(_dt.Rows[0]["F_SJSize"].ToString()), 2.0)) / 4 * 3.1415926);
             _UniversalDataModel.FGczj = int.Parse(_dt.Rows[0]["F_SJSize"].ToString());
             _UniversalDataModel.FGuid = System.Guid.NewGuid().ToString();
             for (int i = 0; i < cells.Count; i++)
             {
                 if (cells[i].Name == JZTestEnum.LDZDL)
                 {
                     _UniversalDataModel.FLz = Convert.ToDouble(cells[i].Value.ToString());
                 }
                 if (cells[i].Name == JZTestEnum.QFL)
                 {
                     _UniversalDataModel.FQflz = Convert.ToDouble(cells[i].Value.ToString());
                 }
                 if (cells[i].Name == JZTestEnum.DHBJ)
                 {
                     _UniversalDataModel.FScl = (Convert.ToDouble(cells[i].Value.ToString()) - Convert.ToDouble(_dt.Rows[0]["F_SJSize"].ToString()) * 5) / Convert.ToDouble(_dt.Rows[0]["F_SJSize"].ToString()) * 5;
                 }
             }
             _UniversalDataModel.FOperator = userName;
             _UniversalDataModel.FPzcode   = "";
             _UniversalDataModel.FRtcode   = GetModuleEMCRTCode(moduleID);
             _UniversalDataModel.FSbbh     = machineBH;
             _UniversalDataModel.FSjbh     = _dt.Rows[0]["F_SJBH"].ToString();
             _UniversalDataModel.FSoftcom  = "北京金舟神创科技发展有限公司";
             _UniversalDataModel.FSysj     = tempRealTimeData.Split('|')[0];
             _UniversalDataModel.FVender   = "北京金舟神创科技发展有限公司";
             _UniversalDataModel.FWtbh     = wtbh;
             _UniversalDataModel.FWy       = "0";
             _UniversalDataModel.FYskllz   = tempRealTimeData.Split('|')[1];
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
     }
     return(_UniversalDataModel);
 }
Example #14
0
    public void LoadReport(string DSource, string DName, string UID, string PWD, string TestRoomCode)
    {
        try
        {
            string _TempStr = @"
                            Select m.reportsheetid,d.Data 
                            from [dbo].[sys_document] d 
                            join [dbo].[sys_module] m on d.ModuleId = m.ID AND m.ID ='E77624E9-5654-4185-9A29-8229AAFDD68B'
                            where testroomcode ='{0}' ";


            #region 查询数据

            DataSet Ds = new DataSet();
            using (SqlConnection _Conn = new SqlConnection("Data Source=" + DSource + ";Initial Catalog=" + DName + ";User ID=" + UID + ";Pwd=" + PWD))
            {
                _Conn.Open();
                using (SqlCommand _Cmd = new SqlCommand(string.Format(_TempStr, TestRoomCode), _Conn))
                {
                    using (SqlDataAdapter _Adp = new SqlDataAdapter(_Cmd))
                    {
                        _Adp.Fill(Ds);
                        if (Ds.Tables[0].Rows.Count > 0)
                        {
                            sheetDataAreaCells = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(Ds.Tables[0].Rows[0]["Data"].ToString());
                        }
                        else
                        {
                            throw new Exception("占无报告数据");
                        }
                    }
                }
                _Conn.Close();
            }


            #endregion
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }
Example #15
0
        public static FpSpread GetModuleByID(Guid moduleID, JZDocument document, String DBName)
        {
            if (moduleList.ContainsKey(moduleID))
            {
                return(moduleList[moduleID]);
            }
            else
            {
                FpSpread fpSpread = new FpSpread();
                try
                {
                    Dictionary <Guid, SheetView>            SheetCollection = new Dictionary <Guid, SheetView>();
                    List <FarPoint.CalcEngine.FunctionInfo> Infos           = DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "GetFunctionInfosNew", new object[] { }, DBName) as List <FarPoint.CalcEngine.FunctionInfo>;

                    foreach (JZSheet sheet in document.Sheets)
                    {
                        String    xml       = DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "GetSheetXMLByID", new object[] { sheet.ID }, DBName).ToString();
                        String    sheetXML  = JZCommonHelper.GZipDecompressString(xml);
                        SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                        SheetView.Tag = sheet.ID;
                        SheetView.Cells[0, 0].Value = "";
                        SheetView.Protect           = true;

                        fpSpread.Sheets.Add(SheetView);

                        SheetCollection.Add(sheet.ID, SheetView);

                        foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos)
                        {
                            SheetView.AddCustomFunction(Info);
                        }
                    }
                    moduleList.Add(moduleID, fpSpread);
                }
                catch (Exception ex)
                {
                    logger.Error("采集构造Farpoint组件错误:" + ex.Message);
                    return(null);
                }
                return(fpSpread);
            }
        }
Example #16
0
        private void DealCaiJi(String DBName, Guid DataID, Guid moduleID)
        {
            String     docString = DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "GetDocumentByID", new object[] { DataID }, DBName).ToString();
            JZDocument doc       = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(docString);

            if (doc != null)
            {
                FpSpread sp = ModuleCatch.GetModuleByID(moduleID, doc, DBName);
                if (sp == null)
                {
                    return;
                }
                List <JZFormulaData> CrossSheetLineFormulaInfos = DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "GetLineFormulaByModuleIndex", new object[] { moduleID }, DBName) as List <JZFormulaData>;
                ProcessDoc(doc, sp, CrossSheetLineFormulaInfos);
                DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "SyncSaveDoc", new object[] { doc, moduleID }, DBName);
            }
            else
            {
                logger.Info("【" + DBName + "】,[" + DataID + "] DealCaiJi is empty.");
            }
        }
        /// <summary>
        /// 上传数据到工管中心
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="moduleID"></param>
        /// <param name="stadiumID"></param>
        /// <param name="wtbh"></param>
        /// <param name="testRoomCode"></param>
        /// <param name="seriaNumber"></param>
        /// <param name="userName"></param>
        /// <param name="cells"></param>
        /// <param name="realTimeData"></param>
        /// <param name="machineBH"></param>
        /// <returns></returns>
        public bool UpdateToEMC(JZDocument doc, Guid moduleID, Guid stadiumID, String wtbh, String testRoomCode,
                                Int32 seriaNumber, String userName, List <JZTestCell> cells, String realTimeData, string machineBH)
        {
            string tempMachineType = GetModuleTypeByID(moduleID);
            string _ErrorMsg       = string.Empty;

            EMCServiceReference.DataInterfaceClient _DataInterfaceClient = new Yqun.BO.BusinessManager.EMCServiceReference.DataInterfaceClient();
            if (tempMachineType == "1")
            {
                if (_DataInterfaceClient.UploadPressureData(out _ErrorMsg, GetPressureDataModel(doc, moduleID, stadiumID, wtbh, testRoomCode, seriaNumber, userName, cells, realTimeData, machineBH)) == -1)
                {
                    logger.Error("上传工管中心压力机数据错误:" + _ErrorMsg);
                }
            }
            if (tempMachineType == "2")
            {
                if (_DataInterfaceClient.UploadUniversalData(out _ErrorMsg, GetUniversalDataModel(doc, moduleID, stadiumID, wtbh, testRoomCode, seriaNumber, userName, cells, realTimeData, machineBH)) == -1)
                {
                    logger.Error("上传工管中心万能机数据错误:" + _ErrorMsg);
                }
            }
            return(false);
        }
Example #18
0
        public void SaveEditLog(JZDocument oldDoc, JZDocument newDoc, String optType, Boolean relationRequestChange, Sys_Document docBase)
        {
            ThreadParameter p = new ThreadParameter();

            p.OldDoc = oldDoc;
            p.NewDoc = newDoc;
            ApplicationContext context = ApplicationContext.Current;

            p.UserName              = context.UserName;
            p.IsAdministrator       = context.IsAdministrator;
            p.OptType               = optType;
            p.RelationRequestChange = relationRequestChange;
            p.DocBase               = docBase;


            p.LineID       = ApplicationContext.Current.InProject.Index;
            p.TestRoomCode = ApplicationContext.Current.InTestRoom.Code;
            p.SegmentName  = ApplicationContext.Current.InSegment.Description;
            p.CompanyName  = ApplicationContext.Current.InCompany.Description;
            p.TestRoomName = ApplicationContext.Current.InTestRoom.Description;
            p.LineName     = ApplicationContext.Current.InProject.Description;

            ThreadPool.QueueUserWorkItem(new WaitCallback(Execute), p);
        }
Example #19
0
        public bool ProcessFactory(Guid documentID, Sys_Module module, Dictionary <string, Object> result, JZDocument document)
        {
            var factoryName = "";
            var factorySet  = module.StatisticsSettings.Find(m => m.BindField == "FactoryName");

            if (factorySet == null)
            {
                Logger.Error("获取到的厂家名称配置项为空");
                return(true);
            }

            factoryName = GetCellValue(document.Sheets.Find(m => m.ID == factorySet.SheetID), factorySet.CellName) as string;
            if (string.IsNullOrEmpty(factoryName))
            {
                Logger.Error("获取到的厂家名称为空, DocumentID:" + documentID);
                return(true);
            }

            Sys_Factory factory = null;

            if (Factories.ContainsKey(factoryName))
            {
                factory = Factories[factoryName];
            }
            else
            {
                var table = CallLocalMethod(Uri, DLL, "GetFactoryByName", new object[] { factoryName }) as DataTable;
                if (table == null || table.Rows.Count == 0)
                {
                    factory             = new Sys_Factory();
                    factory.FactoryID   = Guid.NewGuid();
                    factory.FactoryName = factoryName;
                    factory.CreateTime  = DateTime.Now;
                    var resultNewFactory = CallLocalMethod(Uri, DLL, "NewFactory", new object[] { factory }) as string;
                    if (string.IsNullOrEmpty(resultNewFactory))
                    {
                        Factories[factoryName] = factory;
                    }
                    else
                    {
                        Logger.Error("添加厂家时失败, 信息:" + resultNewFactory);
                    }
                }
                else
                {
                    factory             = new Sys_Factory();
                    factory.FactoryID   = new Guid(Convert.ToString(table.Rows[0]["FactoryID"]));
                    factory.FactoryName = Convert.ToString(table.Rows[0]["FactoryName"]);
                }
            }

            if (factory != null)
            {
                result["FactoryID"]   = factory.FactoryID;
                result["FactoryName"] = factoryName;
            }

            return(true);
        }
Example #20
0
 public void Preloading(SheetView[] sheets, JZDocument document)
 {
     LoadSheets   = sheets;
     LoadDocument = document;
 }
        /// <summary>
        /// 将要Post给铁道部的数据进行打包
        /// </summary>
        /// <param name="posturl">上传URL</param>
        /// <param name="documentID">资料ID</param>
        /// <param name="moduleID">模板ID</param>
        /// <param name="stadiumID">龄期ID</param>
        /// <param name="wtbh">委托编号</param>
        /// <param name="testRoomCode">实验室编码</param>
        /// <param name="seriaNumber">当前试验组数或根数</param>
        /// <param name="userName">用户名称</param>
        /// <param name="testData">试验数据</param>
        /// <param name="realTimeData">实时数据</param>
        /// <param name="totalNumber">总组数或根数</param>
        /// <returns></returns>
        public string PostDataToTDB(JZDocument doc, Guid moduleID, Guid stadiumID, String wtbh, String testRoomCode,
                                    Int32 seriaNumber, String userName, List <JZTestCell> cells, String realTimeData, string machineBH, string UpdloadInfo, string UploadCode)
        {
            string postUrl = string.Empty;
            string json    = string.Empty;
            string QMjson  = string.Empty;

            try
            {
                logger.Error("开始执行:PostData方法");

                //将具体的试验数据生成json字符串并进行64位加密
                string tempRealTimeData = GetYSLZ(realTimeData);
                if (_StringBuilder.Length > 0)
                {
                    _StringBuilder.Remove(0, _StringBuilder.Length);
                }

                logger.Error("开始拼接字符串");

                _StringBuilder.Append("MK=2&");
                string tempMachineType = GetModuleTypeByID(moduleID);
                if (tempMachineType != string.Empty)
                {
                    logger.Error("开始拼接机器类型和相关的数据JOSN");
                    if (tempMachineType == "1")
                    {
                        postUrl = System.Configuration.ConfigurationManager.AppSettings["YLJURL"];
                        _StringBuilder.Append("Gn=1&");
                    }
                    else
                    {
                        postUrl = System.Configuration.ConfigurationManager.AppSettings["WNJURL"];
                        _StringBuilder.Append("Gn=2&");
                    }
                }
                else
                {
                    return(string.Empty);
                }
                _StringBuilder.Append("Bbh=1&");
                _StringBuilder.Append("kfsbh=北京金舟科技发展有限公司&");

                //设备编号
                _StringBuilder.Append("sbh=&");

                _StringBuilder.Append("fssj=" + DateTime.Now.ToString() + "&");
                _StringBuilder.Append("zwcd=" + json.Length + "&");
                _StringBuilder.Append("jmfs=1&");
                if (UploadCode == "0")
                {
                    _StringBuilder.Append("sfqm=1&");
                }
                else
                {
                    _StringBuilder.Append("sfqm=0&");
                }
                _StringBuilder.Append("ylcs=2&");
                _StringBuilder.Append("sjjy=123&");
                _StringBuilder.Append("sjqm=&");
                _StringBuilder.Append("jmzw=" + UpdloadInfo);
                _StringBuilder.Append("&zsxh=");
                _StringBuilder.Append("&cfbs=0");
                _StringBuilder.Append("&kzbh=" + System.Configuration.ConfigurationManager.AppSettings["kzbh"]);

                logger.Error("字符串拼接完成");
                return(UpdateToInfoCenter(postUrl));
            }
            catch (Exception ex)
            {
                logger.Error("拼接字符串错误:" + ex.ToString());
                return(string.Empty);
            }
        }
Example #22
0
        private void DataItemSelector_Load(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            try
            {
                fpSpread1.Sheets.Clear();

                if (LoadDocument == null)
                {
                    LoadDocument = ModuleHelperClient.GetDefaultDocument(ModuleID);
                }

                var sheetsCache = new List <SheetView>();
                foreach (var sheet in LoadDocument.Sheets)
                {
                    ProgressScreen.Current.SetStatus = "正在初始化表单‘" + sheet.Name + "’";
                    var sheetView = GetLoadedSheet(sheet.Name);

                    if (sheetView == null)
                    {
                        var sheetXML = ModuleHelperClient.GetSheetXMLByID(sheet.ID);
                        sheetView           = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                        sheetView.SheetName = sheet.Name;
                    }

                    sheetView.Tag           = sheet.ID;
                    sheetView.OperationMode = OperationMode.ReadOnly;
                    fpSpread1.Sheets.Add(sheetView);
                    sheetsCache.Add(sheetView);

                    foreach (JZCell dataCell in sheet.Cells)
                    {
                        sheetView.Cells[dataCell.Name].BackColor = Color.LightPink;
                    }
                }

                LoadSheets = sheetsCache.ToArray();

                //if (CellName != ""&&SheetID!=Guid.Empty)
                //{
                //    SheetView s = null;
                //    foreach (SheetView sheet in fpSpread1.Sheets)
                //    {
                //        if (new Guid(sheet.Tag.ToString()) == SheetID)
                //        {
                //            s = sheet;
                //            break;
                //        }
                //    }
                //    if (s != null)
                //    {
                //        fpSpread1.ActiveSheet = s;
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show("加载模板出错!\r\n原因:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.RemoveOwnedForm(ProgressScreen.Current);
            ProgressScreen.Current.CloseSplashScreen();
            Activate();
        }
Example #23
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        sys_line sysBaseLine = System.Web.HttpContext.Current.Session["SysBaseLine"] as sys_line;

        if (sysBaseLine.IsActive == 1)
        {
            string  SQL = "SELECT * FROM dbo.sys_document WHERE  ModuleID='BA23C25D-7C79-4CB3-A0DC-ACFA6C285295' ";
            DataSet ds  = DbHelperSQL.Query(SQL);
            SQL = " TRUNCATE TABLE biz_machinelist ";
            DbHelperSQL.Query(SQL);

            DateTime d_min = DateTime.Parse(SqlDateTime.MinValue.ToString());
            DateTime d_max = DateTime.Parse(SqlDateTime.MaxValue.ToString());



            if (ds != null)
            {
                List <biz_machinelist> list = new List <biz_machinelist>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string     str = dr["Data"].ToString();
                    JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(str);
                    if (doc != null)
                    {
                        #region
                        for (int i = 6; i < 32; i++)
                        {
                            biz_machinelist biz = new biz_machinelist();
                            biz.SCTS = DateTime.Parse(dr["CreatedTime"].ToString());
                            biz.SCPT = dr["TestRoomCode"].ToString();
                            //int n=0;
                            //if (Int32.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "A" + i).ToString(),out n))
                            //{
                            //    biz.col_norm_A6 = Int32.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "A" + i).ToString());
                            //}
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i) != null)
                            {
                                biz.col_norm_B6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "C" + i) != null)
                            {
                                biz.col_norm_C6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "C" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D" + i) != null)
                            {
                                biz.col_norm_D6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i) != null)
                            {
                                biz.col_norm_E6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "F" + i) != null)
                            {
                                biz.col_norm_F6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "F" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G" + i) != null)
                            {
                                biz.col_norm_G6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i) != null)
                            {
                                DateTime date = new DateTime();
                                if (DateTime.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString(), out date) == false)
                                {
                                    biz.col_norm_H6 = null;
                                }
                                else
                                {
                                    if (DateTime.Compare(d_min, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString())) < 0 && DateTime.Compare(d_max, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString())) >= 0)
                                    {
                                        biz.col_norm_H6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString());
                                    }
                                    else
                                    {
                                        biz.col_norm_H6 = null;
                                    }
                                }
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "I" + i) != null)
                            {
                                biz.col_norm_I6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "I" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "J" + i) != null)
                            {
                                biz.col_norm_J6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "J" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i) != null)
                            {
                                biz.col_norm_K6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L" + i) != null)
                            {
                                biz.col_norm_L6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i) != null)
                            {
                                biz.col_norm_M6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i) != null)
                            {
                                DateTime date = new DateTime();
                                if (DateTime.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString(), out date) == false)
                                {
                                    biz.col_norm_N6 = null;
                                }
                                else
                                {
                                    //biz.col_norm_N6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString());
                                    if (DateTime.Compare(d_min, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString())) < 0 && DateTime.Compare(d_max, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString())) >= 0)
                                    {
                                        biz.col_norm_N6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString());
                                    }
                                    else
                                    {
                                        biz.col_norm_N6 = null;
                                    }
                                }
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i) != null)
                            {
                                DateTime date = new DateTime();
                                if (DateTime.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString(), out date) == false)
                                {
                                    biz.col_norm_O6 = null;
                                }
                                else
                                {
                                    //biz.col_norm_O6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString());
                                    if (DateTime.Compare(d_min, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString())) < 0 && DateTime.Compare(d_max, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString())) >= 0)
                                    {
                                        biz.col_norm_O6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString());
                                    }
                                    else
                                    {
                                        biz.col_norm_O6 = null;
                                    }
                                }
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "P" + i) != null)
                            {
                                biz.col_norm_P6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "P" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "Q" + i) != null)
                            {
                                biz.col_norm_Q6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "Q" + i).ToString();
                            }
                            if (biz.col_norm_B6 == null && biz.col_norm_C6 == null && biz.col_norm_D6 == null && biz.col_norm_E6 == null && biz.col_norm_F6 == null)
                            {
                            }
                            else
                            {
                                list.Add(biz);
                            }
                        }
                        #endregion
                    }
                }

                #region
                foreach (var item in list)
                {
                    long n = 0;
                    n = Add(item);
                }
                #endregion

                SQL = "DELETE dbo.biz_machinelist WHERE  col_norm_B6='' AND col_norm_C6='' AND col_norm_D6='' AND col_norm_E6='' AND col_norm_F6='' AND col_norm_G6='' ";
                DbHelperSQL.Query(SQL);
                Label1.Text = "执行成功";
            }
        }
    }
Example #24
0
        private void LogDialog_Load(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);
            InitLogCategoryInfo();
            Dictionary <Guid, SheetView> SheetCollection = new Dictionary <Guid, SheetView>();

            try
            {
                List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos();
                FpSpread.Sheets.Clear();
                if (dataID == Guid.Empty)
                {
                    return;
                }
                JZDocument document        = DocumentHelperClient.GetDocumentByID(dataID);
                JZDocument defaultDocument = ModuleHelperClient.GetDefaultDocument(moduleID);

                List <JZFormulaData> CrossSheetFormulaInfos = ModuleHelperClient.GetFormulaByModuleIndex(moduleID);

                foreach (JZSheet sheet in defaultDocument.Sheets)
                {
                    ProgressScreen.Current.SetStatus = "正在初始化表单‘" + sheet.Name + "’";
                    String    sheetXML  = ModuleHelperClient.GetSheetXMLByID(sheet.ID);
                    SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                    SheetView.Tag               = sheet.ID;
                    SheetView.SheetName         = sheet.Name;
                    SheetView.Cells[0, 0].Value = "";
                    SheetView.Protect           = true;
                    FpSpread.Sheets.Add(SheetView);

                    SheetCollection.Add(sheet.ID, SheetView);
                    foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos)
                    {
                        SheetView.AddCustomFunction(Info);
                    }
                    foreach (JZCell dataCellDefault in sheet.Cells)
                    {
                        Cell    cell     = SheetView.Cells[dataCellDefault.Name];
                        Object  value    = JZCommonHelper.GetCellValue(document, sheet.ID, dataCellDefault.Name);
                        Boolean hasValue = true;
                        if (value == null || value.ToString() == "")
                        {
                            hasValue = false;
                        }
                        if (cell != null)
                        {
                            cell.Font = defaultFont;
                            if (cell.CellType is DownListCellType)
                            {
                                DownListCellType CellType = cell.CellType as DownListCellType;
                                CellType.DropDownButton = false;
                                CellType.DesignMode     = false;
                                cell.Value = value;
                            }
                            else if (cell.CellType is TextCellType)
                            {
                                TextCellType CellType = cell.CellType as TextCellType;
                                if (CellType.FieldType.Description == FieldType.Text.Description)
                                {
                                    CellType.Multiline = true;
                                    CellType.WordWrap  = true;
                                }
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is LongTextCellType)
                            {
                                LongTextCellType CellType = cell.CellType as LongTextCellType;
                                if (CellType.FieldType.Description == FieldType.LongText.Description)
                                {
                                    CellType.Multiline = true;
                                    CellType.WordWrap  = true;
                                }
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is DateTimeCellType)
                            {
                                DateTimeCellType CellType = cell.CellType as DateTimeCellType;
                                CellType.MinimumDate = new DateTime(1753, 1, 1);
                                CellType.MaximumDate = new DateTime(9999, 12, 31);
                                cell.Value           = value;
                            }
                            else if (cell.CellType is RichTextCellType)
                            {
                                RichTextCellType CellType = cell.CellType as RichTextCellType;
                                CellType.Multiline = false;
                                CellType.WordWrap  = false;
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is NumberCellType)
                            {
                                NumberCellType CellType = cell.CellType as NumberCellType;
                                CellType.MaximumValue = 999999999.9999;
                                CellType.MinimumValue = -999999999.9999;
                                cell.Value            = value;
                            }
                            else if (cell.CellType is MaskCellType)
                            {
                                MaskCellType CellType = cell.CellType as MaskCellType;
                                CellType.Mask = "00000000000000000000000000000000000";
                                if (CellType.CustomMaskCharacters != null && CellType.CustomMaskCharacters.Length > 0)
                                {
                                    CellType.CustomMaskCharacters[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-()()复检";
                                }
                                cell.Value = value;
                            }
                            else if (cell.CellType is ImageCellType)
                            {
                                if (value != null)
                                {
                                    cell.Value = JZCommonHelper.StringToBitmap(value.ToString());
                                }
                            }
                            else
                            {
                                cell.Value = value;
                            }
                        }
                    }
                }

                ProgressScreen.Current.SetStatus = "正在初始化跨表公式...";

                foreach (JZFormulaData formula in CrossSheetFormulaInfos)
                {
                    SheetView Sheet = SheetCollection[formula.SheetIndex];
                    try
                    {
                        Sheet.Cells[formula.RowIndex, formula.ColumnIndex].Formula = formula.Formula;
                    }
                    catch
                    {
                    }
                }

                FpSpread.LoadFormulas(true);

                ProgressScreen.Current.SetStatus = "正在显示资料...";

                UpdateChart();
                UpdateEquation();
                SetNotes();
                //设置只读模式
                if (ReadOnly)
                {
                    foreach (SheetView sheet in FpSpread.Sheets)
                    {
                        sheet.OperationMode = OperationMode.ReadOnly;
                    }
                }
            }
            catch (TimeoutException ex1)
            {
                MessageBox.Show("网络原因造成数据无法访问,请检查本机网络连接,或稍后再试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("加载试验模板出错!\r\n原因:" + (ex.InnerException != null ? ex.InnerException.Message : ex.Message), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                try
                {
                    this.RemoveOwnedForm(ProgressScreen.Current);
                    ProgressScreen.Current.CloseSplashScreen();
                    this.Activate();
                }
                catch (Exception ex1) { }
            }
        }
Example #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String id = Request.Params["id"];
            if (!String.IsNullOrEmpty(id))
            {
                sys_line sysBaseLine = System.Web.HttpContext.Current.Session["SysBaseLine"] as sys_line;
                if (sysBaseLine.IsActive == 0)
                {
                    #region
                    BLL_UserInfo bll = new BLL_UserInfo();
                    DataTable    dt  = bll.GetUserInfo(id);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        lbl_xingming.Text        = dt.Rows[0]["col_norm_D6"].ToString();
                        lbl_xingbie.Text         = dt.Rows[0]["col_norm_G6"].ToString();
                        lbl_nianling.Text        = dt.Rows[0]["col_norm_K6"].ToString();
                        lbl_jishuzhicheng.Text   = dt.Rows[0]["col_norm_D7"].ToString();
                        lbl_zhiwu.Text           = dt.Rows[0]["col_norm_G7"].ToString();
                        lbl_gongzuonianxian.Text = dt.Rows[0]["col_norm_K7"].ToString();
                        lbl_zhuanye.Text         = dt.Rows[0]["col_norm_D8"].ToString();
                        lbl_xueli.Text           = dt.Rows[0]["col_norm_G8"].ToString();


                        try
                        {
                            lbl_biyeshijian.Text = Convert.ToDateTime(dt.Rows[0]["col_norm_K8"].ToString()).ToShortDateString();
                        }
                        catch
                        {
                            lbl_biyeshijian.Text = dt.Rows[0]["col_norm_K8"].ToString();
                        }

                        lbl_lianxidianhua.Text = dt.Rows[0]["col_norm_D9"].ToString();
                        lbl_biyexuexiao.Text   = dt.Rows[0]["col_norm_G9"].ToString();

                        //dt.Rows[0]["col_norm_L6"].ToString()

                        #region
                        StringBuilder sb1 = new StringBuilder();
                        if (!string.IsNullOrEmpty(dt.Rows[0]["col_norm_L6"].ToString()))
                        {
                            string pathname = dt.Rows[0]["ID"].ToString();
                            string fullPath = Server.MapPath("../userphoto/ ") + pathname + ".jpg";
                            if (!File.Exists(fullPath))
                            {
                                object o = dt.Rows[0]["col_norm_L6"];
                                var    _tempMemoryStream = new MemoryStream((byte[])o);
                                System.Drawing.Image img = System.Drawing.Image.FromStream(_tempMemoryStream);
                                img.Save(fullPath);
                                _tempMemoryStream.Close();
                            }
                            else
                            {
                            }
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../userphoto/" + pathname + ".jpg\" />");
                        }
                        else
                        {
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../images/nohead.png\" />");
                        }
                        Literal3.Text = sb1.ToString();
                        #endregion


                        #region
                        if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B14"].ToString()))
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 14; i < 28; i++)
                            {
                                if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B" + i + ""].ToString()))
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + dt.Rows[0]["col_norm_B" + i + ""].ToString() + "</td>");
                                    sb.Append("<td colspan=\"3\">" + dt.Rows[0]["col_norm_E" + i + ""].ToString() + "</td>");
                                    sb.Append("<td>" + dt.Rows[0]["col_norm_K" + i + ""].ToString() + "</td>");
                                    sb.Append("<td>" + dt.Rows[0]["col_norm_M" + i + ""].ToString() + "</td></tr>");
                                }
                            }
                            Literal1.Text = sb.ToString();
                        }
                        else
                        {
                            tr_gzjl.Style["display"]    = "none";
                            tr_gzjl_mx.Style["display"] = "none";
                        }

                        if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B31"].ToString()))
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 31; i < 37; i++)
                            {
                                if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B" + i + ""].ToString()))
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + dt.Rows[0]["col_norm_B" + i + ""].ToString() + "</td>");
                                    sb.Append("<td colspan=\"4\">" + dt.Rows[0]["col_norm_E" + i + ""].ToString() + "</td>");


                                    try
                                    {
                                        string[] Temp = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(dt.Rows[0]["col_norm_K" + i + ""].ToString());

                                        sb.Append("<td>" + Temp[0] + "<img src='data:image/gif;base64," + Temp[1] + "' /></td></tr>");
                                    }
                                    catch
                                    {
                                        sb.Append("<td>" + dt.Rows[0]["col_norm_K" + i + ""].ToString() + "' /></td></tr>");
                                    }
                                }
                            }
                            Literal2.Text = sb.ToString();
                        }
                        else
                        {
                            tr_pxjl.Style["display"]    = "none";
                            tr_pxjl_mx.Style["display"] = "none";
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    string SQL = "SELECT * FROM dbo.sys_document WHERE ID='" + id + "'";

                    DataSet    ds  = DbHelperSQL.Query(SQL);
                    string     str = ds.Tables[0].Rows[0]["Data"].ToString();
                    JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(str);
                    if (doc != null)
                    {
                        #region
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D6") != null)
                        {
                            lbl_xingming.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D6").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G6") != null)
                        {
                            lbl_xingbie.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G6").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K6") != null)
                        {
                            lbl_nianling.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K6").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D7") != null)
                        {
                            lbl_jishuzhicheng.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D7").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G7") != null)
                        {
                            lbl_zhiwu.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G7").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K7") != null)
                        {
                            lbl_gongzuonianxian.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K7").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D8") != null)
                        {
                            lbl_zhuanye.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D8").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G8") != null)
                        {
                            lbl_xueli.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G8").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K8") != null)
                        {
                            lbl_biyeshijian.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K8").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D9") != null)
                        {
                            lbl_lianxidianhua.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D9").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G9") != null)
                        {
                            lbl_biyexuexiao.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G9").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D10") != null)
                        {
                            lbl_idcard.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D10").ToString();
                        }
                        #endregion

                        #region
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B14") != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 14; i < 28; i++)
                            {
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "") != null)
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<tr><td colspan=\"2\"></td>");
                                }
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "") != null)
                                {
                                    sb.Append("<td colspan=\"3\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<td colspan=\"3\"></td>");
                                }

                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "") != null)
                                {
                                    sb.Append("<td>" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<td></td>");
                                }

                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i + "") != null)
                                {
                                    sb.Append("<td>" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i + "").ToString() + "</td></tr>");
                                }
                                else
                                {
                                    sb.Append("<td></td></tr>");
                                }
                            }
                            Literal1.Text = sb.ToString();
                        }
                        else
                        {
                            tr_gzjl.Style["display"]    = "none";
                            tr_gzjl_mx.Style["display"] = "none";
                        }


                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B31") != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 31; i < 37; i++)
                            {
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "") != null)
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<tr><td colspan=\"2\"></td>");
                                }
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "") != null)
                                {
                                    sb.Append("<td colspan=\"4\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<td colspan=\"4\"></td>");
                                }

                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "") != null)
                                {
                                    try
                                    {
                                        string[] Temp = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString());

                                        System.Drawing.Image img = BizCommon.JZCommonHelper.StringToBitmap(Temp[1]);

                                        sb.Append("<td>" + Temp[0] + "&nbsp;&nbsp;&nbsp;&nbsp;<a title=\"点击查看大图\" href=\"javascript:Show('" + id + "','" + doc.Sheets[0].ID.ToString() + "'," + i + ")\"><img src='data:image/gif;base64," + Temp[1] + "' height=\"30px;\" /></a></td>");
                                    }
                                    catch
                                    {
                                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString() != "[null,null,null]")
                                        {
                                            sb.Append("<td>" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString() + "</td>");
                                        }
                                        else
                                        {
                                            sb.Append("<td></td>");
                                        }
                                    }
                                }
                                else
                                {
                                    sb.Append("<td></td>");
                                }
                            }
                            Literal2.Text = sb.ToString();
                        }
                        else
                        {
                            tr_pxjl.Style["display"]    = "none";
                            tr_pxjl_mx.Style["display"] = "none";
                        }

                        #endregion

                        #region
                        StringBuilder sb1 = new StringBuilder();


                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L6") != null)
                        {
                            string pathname = id;
                            string fullPath = Server.MapPath("../userphoto/ ") + pathname + ".jpg";
                            if (!File.Exists(fullPath))
                            {
                                object o = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L6");
                                System.Drawing.Image img = null;
                                byte[] bitmapBytes       = System.Convert.FromBase64String(o.ToString());
                                using (MemoryStream memoryStream = new MemoryStream(bitmapBytes))
                                {
                                    img = System.Drawing.Image.FromStream(memoryStream);
                                    img.Save(fullPath);
                                    memoryStream.Close();
                                }
                            }
                            //else
                            //{
                            //    sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../images/nohead.png\" />");
                            //}
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../userphoto/" + pathname + ".jpg\" />");
                        }
                        else
                        {
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../images/nohead.png\" />");
                        }
                        Literal3.Text = sb1.ToString();
                        #endregion
                    }
                }
            }
        }
    }
Example #26
0
        public bool CreatReportInfoXMLFile(UploadSetting[] setArr, String path, DataRow[] drArr, String trCode, int[] wucArr)
        {
            if (File.Exists(path))
            {
                try
                {
                    File.Delete(path);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml("<?xml version=\"1.0\" encoding=\"gb2312\"?><ROOT></ROOT>");
            //logger.Error("CreatReportInfoXMLFile 0");
            for (int i = 0; i < drArr.Length; i++)
            {
                //logger.Error("CreatReportInfoXMLFile drArr i" + i);
                if (setArr[i] != null && setArr[i].Items != null)
                {
                    //logger.Error("CreatReportInfoXMLFile setArr i" + i);
                    XmlElement root = xmldoc.CreateElement(setArr[i].Name);
                    xmldoc.DocumentElement.AppendChild(root);
                    JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(drArr[i]["Data"].ToString());
                    XmlElement ele = null;
                    foreach (var item in setArr[i].Items)
                    {
                        ele = xmldoc.CreateElement(item.Name);
                        String value = "";
                        if (item.NeedSetting)
                        {
                            Object obj = JZCommonHelper.GetCellValue(doc, item.SheetID, item.CellName);
                            if (obj != null)
                            {
                                value = obj.ToString();
                            }
                        }
                        else
                        {
                            switch (item.Name)
                            {
                            case "F_TRCODE":    //试验室编号
                                value = trCode;
                                break;

                            case "F_NEWVERSION":    //试验室编号
                                value = wucArr[i].ToString();
                                break;

                            default:
                                break;
                            }
                        }
                        ele.InnerText = value;
                        root.AppendChild(ele);
                    }
                }
            }
            try
            {
                xmldoc.Save(path);
                return(true);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                return(false);
            }
        }
Example #27
0
        public bool CreatXMLFile(UploadSetting set, String path, JZDocument doc, String trCode)
        {
            if (File.Exists(path))
            {
                try
                {
                    File.Delete(path);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml("<?xml version=\"1.0\" encoding=\"gb2312\"?><ROOT></ROOT>");
            XmlElement root = xmldoc.CreateElement(set.Name);

            xmldoc.DocumentElement.AppendChild(root);

            if (set.Items != null)
            {
                XmlElement ele = null;
                foreach (var item in set.Items)
                {
                    ele = xmldoc.CreateElement(item.Name);
                    String value = "";
                    if (item.NeedSetting)
                    {
                        Object obj = JZCommonHelper.GetCellValue(doc, item.SheetID, item.CellName);
                        if (obj != null)
                        {
                            value = obj.ToString();
                        }
                    }
                    else
                    {
                        switch (item.Name)
                        {
                        case "F_TRCODE":    //试验室编号
                            value = trCode;
                            break;

                        default:
                            break;
                        }
                    }
                    ele.InnerText = value;
                    root.AppendChild(ele);
                }
            }
            try
            {
                xmldoc.Save(path);
                return(true);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                return(false);
            }
        }
Example #28
0
        /// <summary>
        /// 上传试验数据
        /// </summary>
        public void UploadTestDataInfo(string strTestRoomCodeMap, String uploadAddress, String jsdwCode)
        {
            try
            {
                Hashtable testRoomCodeMap = InitTestRoomCodeMap(strTestRoomCodeMap);
//                String sql = @"SELECT top 100 ID,TestRoomCode,Data,WillUploadCount,ModuleID,BGBH,CreatedTime FROM dbo.sys_document WHERE
//            ModuleID NOT IN ('E77624E9-5654-4185-9A29-8229AAFDD68B','08899BA2-CC88-403E-9182-3EF73F5FB0CE',
//            'BA23C25D-7C79-4CB3-A0DC-ACFA6C285295') AND Status>0 AND NeedUpload=1 and BGBH is not null and BGBH<>''  ORDER BY CreatedTime ";//排除人员、设备、试验室
                String         sql   = @"SELECT top 100 ID FROM dbo.sys_document WHERE 
            ModuleID NOT IN ('E77624E9-5654-4185-9A29-8229AAFDD68B','08899BA2-CC88-403E-9182-3EF73F5FB0CE',
            'BA23C25D-7C79-4CB3-A0DC-ACFA6C285295') AND Status>0 AND NeedUpload=1 and BGBH is not null and BGBH<>''  ORDER BY CreatedTime ";//排除人员、设备、试验室
                DataTable      dtIDs = GetDataTable(sql);
                ModuleHelper   mh    = new ModuleHelper();
                DocumentHelper dh    = new DocumentHelper();
                if (dtIDs != null && dtIDs.Rows.Count > 0)
                {
                    String        ksign = "05";//05表示试验数据
                    List <String> files = new List <String>();
                    #region 创建目录
                    String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验数据");
                    DeleteDirAllFile(path);
                    if (!Directory.Exists(path))
                    {
                        try
                        {
                            Directory.CreateDirectory(path);
                        }
                        catch (Exception ee)
                        {
                            logger.Error(ee.Message);
                        }
                    }
                    #endregion
                    #region 回收应用程序池
                    //string strRealPath = System.Web.Hosting.HostingEnvironment.MapPath("~");
                    //logger.Error("strRealPath:" + strRealPath);
                    //strRealPath = strRealPath.Substring(0, strRealPath.Length - 1);
                    //int LastIndex = strRealPath.LastIndexOf('\\');
                    //string AppPoolName = strRealPath.Substring(LastIndex + 1, strRealPath.Length - LastIndex - 1);
                    //logger.Error("AppPoolName:" + AppPoolName);
                    //string method = "Recycle";
                    //try
                    //{
                    //    DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
                    //    DirectoryEntry findPool = appPool.Children.Find(AppPoolName, "IIsApplicationPool");
                    //    findPool.Invoke(method, null);
                    //    appPool.CommitChanges();
                    //    appPool.Close();
                    //    logger.Error("应用程序池名称回收成功");
                    //}
                    //catch (Exception ex)
                    //{
                    //    logger.Error("回收失败:" + ex.Message);
                    //}
                    #endregion
                    StringBuilder   strIDs    = new StringBuilder();
                    UploadSetting[] usArr     = new UploadSetting[dtIDs.Rows.Count];
                    DataRow[]       docRowArr = new DataRow[dtIDs.Rows.Count];
                    int[]           wucArr    = new int[dtIDs.Rows.Count];//WillUploadCount
                    #region 创建资料列表
                    for (int i = 0; i < dtIDs.Rows.Count; i++)
                    {
                        string    strID           = dtIDs.Rows[i]["ID"].ToString();
                        string    strSQL          = "SELECT ID,TestRoomCode,Data,WillUploadCount,ModuleID,BGBH,CreatedTime FROM dbo.sys_document where ID='" + strID + "'";
                        DataTable dt              = GetDataTable(strSQL);
                        String    testRoomCode    = dt.Rows[0]["TestRoomCode"].ToString();
                        string    strModuleID     = dt.Rows[0]["ModuleID"].ToString();
                        string    strBGBH         = dt.Rows[0]["BGBH"].ToString();
                        string    docDateDir      = DateTime.Parse(dt.Rows[0]["CreatedTime"].ToString()).ToString("yyyy/MM/dd");
                        int       WillUploadCount = int.Parse(dt.Rows[0]["WillUploadCount"].ToString());
                        strIDs.AppendFormat("'{0}'", strID);
                        if (i < dt.Rows.Count - 1)
                        {
                            strIDs.Append(",");
                        }
                        Sys_Module    module = mh.GetModuleBaseInfoByID(new Guid(strModuleID));
                        UploadSetting set    = module.UploadSetting;
                        if (set != null)
                        {
                            if (testRoomCodeMap.ContainsKey(testRoomCode))
                            {
                                testRoomCode = testRoomCodeMap[testRoomCode].ToString();
                            }
                            string strSourceFile = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), string.Format("source/{0}/{1}.pdf", docDateDir, strID));
                            string strDestFile   = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), string.Format("Temp/TestDataUpload/试验数据/{0}_{1}.pdf", testRoomCode, strBGBH));
                            if (!File.Exists(strSourceFile))
                            {
                                //logger.Error(string.Format("{1} ID:{0}不存在,生成文件开始", strID, i));
                                #region 生成PDF和图片
                                JZDocument doc      = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(dt.Rows[0]["Data"].ToString());
                                FpSpread   fpSpread = new FpSpread();
                                //int rIndex = 0;
                                //foreach (JZSheet sheet in doc.Sheets)
                                //{
                                //if (rIndex == module.ReportIndex)
                                //{
                                String    sheetXML  = JZCommonHelper.GZipDecompressString(mh.GetSheetXMLByID(doc.Sheets[module.ReportIndex].ID));// mh.GetSheetXMLByID(sheet.ID);
                                SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                                SheetView.Tag = doc.Sheets[module.ReportIndex].ID;
                                SheetView.Cells[0, 0].Value = "";
                                SheetView.Protect           = true;
                                foreach (JZCell dataCell in doc.Sheets[module.ReportIndex].Cells)
                                {
                                    Cell cell = SheetView.Cells[dataCell.Name];

                                    if (cell != null)
                                    {
                                        cell.Value = dataCell.Value;
                                    }
                                }
                                fpSpread.Sheets.Add(SheetView);
                                //}
                                //else
                                //{
                                //    //fpSpread.Sheets.Add(null);
                                //}
                                //sheetXML = null;
                                //SheetView = null;
                                //    rIndex++;
                                //}

                                //自动生成Excel,图片和报告页的pdf
                                SourceHelper sourceHelper = new SourceHelper();
                                sourceHelper.CreateRalationFilesSync(fpSpread, doc.ID, module.ReportIndex, docDateDir);
                                fpSpread.Dispose();
                                doc = null;
                                #endregion
                                logger.Error(string.Format("{1} ID:{0}不存在,生成文件成功", strID, i));
                                //Thread.Sleep(10000);
                            }
                            else
                            {
                                logger.Error(string.Format("{1} ID:{0}存在,不需要生成文件", strID, i));
                            }
                            File.Copy(strSourceFile, strDestFile, true);
                            files.Add(strDestFile);

                            usArr[i]     = set;
                            docRowArr[i] = dt.Rows[0];
                            wucArr[i]    = WillUploadCount;
                            //JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject<JZDocument>(dt.Rows[i]["Data"].ToString());
                            //String fileName = Path.Combine(path, dt.Rows[i]["ID"].ToString() + ".xml");
                            //if (CreatXMLFile(set, fileName, doc, testRoomCode))
                            //{
                            //    files.Add(fileName);
                            //}
                        }
                        else
                        {
                            usArr[i]     = null;
                            docRowArr[i] = dt.Rows[0];
                            wucArr[i]    = WillUploadCount;
                            logger.Error("未找到该模板对应的上传设置,资料ID:" + strID);
                        }
                    }
                    #endregion
                    //logger.Error("reportInfo 0");
                    String fileName = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验数据/reportInfo.xml");
                    //生成reportInfo.xml
                    CreatReportInfoXMLFile(usArr, fileName, docRowArr, jsdwCode, wucArr);
                    //logger.Error("reportInfo 1");
                    files.Add(fileName);

                    #region   资料
                    if (files.Count > 0)
                    {
                        String zipFile = Path.Combine(path, "试验报告.zip");
                        if (File.Exists(zipFile))
                        {
                            try
                            {
                                File.Delete(zipFile);
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message);
                            }
                        }
                        if (JZCommonHelper.CreateZipFile(files, zipFile))
                        {
                            FileStream stream = null;
                            stream = new FileInfo(zipFile).OpenRead();
                            Byte[] buffer = new Byte[stream.Length];
                            stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                            stream.Close();
                            String result = UploadToServer(uploadAddress, buffer, ksign, jsdwCode);
                            if (result == "1")
                            {
                                logger.Error("试验报告上传成功");
                                if (strIDs.Length > 0)
                                {
                                    dh.UpdateDocumentNeedUpload(strIDs.ToString());
                                }
                            }
                            else
                            {
                                logger.Error("试验报告上传失败,返回值为:" + result);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    logger.Info("未找到试验数据信息");
                }
            }
            catch (Exception ex)
            {
                logger.Error("UploadTestDataInfo error:" + ex.ToString());
            }
        }
Example #29
0
        /// <summary>
        ///上传试验室综合情况
        /// </summary>
        public void UploadTestRoomInfo(string strTestRoomCodeMap, String uploadAddress, String jsdwCode)
        {
            try
            {
                Hashtable     testRoomCodeMap = InitTestRoomCodeMap(strTestRoomCodeMap);
                String        moduleID        = "E77624E9-5654-4185-9A29-8229AAFDD68B"; //试验室综合情况
                String        ksign           = "01";                                   //01表示试验室
                UploadSetting set             = GetUploadSettingByModuleID(moduleID);
                if (set != null)
                {
                    String        sql   = "SELECT TestRoomCode,Data FROM dbo.sys_document WHERE ModuleID='" + moduleID + "' AND Status>0";
                    DataTable     dt    = GetDataTable(sql);
                    List <String> files = new List <string>();
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验室基本属性");
                        DeleteDirAllFile(path);
                        if (!Directory.Exists(path))
                        {
                            try
                            {
                                Directory.CreateDirectory(path);
                            }
                            catch (Exception ee)
                            {
                                logger.Error(ee.Message);
                            }
                        }
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            String testRoomCode = dt.Rows[i]["TestRoomCode"].ToString();
                            if (testRoomCodeMap.ContainsKey(testRoomCode))
                            {
                                testRoomCode = testRoomCodeMap[testRoomCode].ToString();
                            }

                            JZDocument doc      = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(dt.Rows[i]["Data"].ToString());
                            String     fileName = Path.Combine(path, testRoomCode + ".xml");
                            if (CreatXMLFile(set, fileName, doc, testRoomCode))
                            {
                                files.Add(fileName);
                            }
                            doc = null;
                            Thread.Sleep(3000);
                        }
                        if (files.Count > 0)
                        {
                            String zipFile = Path.Combine(path, "试验室基本属性.zip");
                            if (File.Exists(zipFile))
                            {
                                try
                                {
                                    File.Delete(zipFile);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                }
                            }
                            if (JZCommonHelper.CreateZipFile(files, zipFile))
                            {
                                FileStream stream = null;
                                stream = new FileInfo(zipFile).OpenRead();
                                Byte[] buffer = new Byte[stream.Length];
                                stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                                stream.Close();
                                String result = UploadToServer(uploadAddress, buffer, ksign, jsdwCode);
                                if (result == "1")
                                {
                                    logger.Error("试验室综合情况数据上传成功");
                                }
                                else
                                {
                                    logger.Error("试验室综合情况数据上传失败,返回值为:" + result);
                                }
                            }
                        }
                    }
                    else
                    {
                        logger.Error("未找到试验室综合情况信息");
                    }
                }
                else
                {
                    logger.Error("未找到该模板对应的上传设置");
                }
            }
            catch (Exception ex)
            {
                logger.Error("UploadTestRoomInfo error:" + ex.ToString());
            }
        }
Example #30
0
        /// <summary>
        /// 生成人员头像(硬编码身份证与头像单元格位置)
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="files"></param>
        /// <param name="path"></param>
        private void ProcessPersonPhoto(DataRow[] drArr, List <String> files, String path)
        {
            //logger.Error("ProcessPersonPhoto 0");
            foreach (DataRow dr in drArr)
            {
                JZDocument doc      = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(dr["Data"].ToString());
                String     personID = "";
                foreach (var item in doc.Sheets[0].Cells)
                {
                    if (item.Name == "D10")//身份证
                    {
                        if (item.Value != null)
                        {
                            personID = item.Value.ToString();
                            break;
                        }
                    }
                }
                //logger.Error("personID:" + personID);
                if (personID != "")
                {
                    String photoFile = Path.Combine(path, personID + ".jpg");
                    if (!files.Contains(photoFile))
                    {
                        try
                        {
                            Boolean saved = false;
                            foreach (var item in doc.Sheets[0].Cells)
                            {
                                if (item.Name == "L6")//照片
                                {
                                    if (item.Value != null)
                                    {
                                        if (File.Exists(photoFile))
                                        {
                                            try
                                            {
                                                File.Delete(photoFile);
                                            }
                                            catch (Exception ex)
                                            {
                                                logger.Error(ex.Message);
                                            }
                                        }

                                        byte[] bitmapBytes = System.Convert.FromBase64String(item.Value.ToString());
                                        using (MemoryStream memoryStream = new MemoryStream(bitmapBytes))
                                        {
                                            Image image = Image.FromStream(memoryStream);
                                            image.Save(photoFile, ImageFormat.Jpeg);
                                        }

                                        saved = true;
                                    }
                                    break;
                                }
                            }
                            if (saved)
                            {
                                files.Add(photoFile);
                            }
                        }
                        catch (Exception e)
                        {
                            logger.Error(e.Message);
                        }
                    }
                }
            }
        }