Example #1
0
        public static string addOrEdit(string strXml)
        {
            string xml = Operation.dealWithXml(strXml);

            DicCache.getInstance().refresh("AFFAIRTYPE");
            return(xml);
        }
Example #2
0
        /// <summary>
        /// 班级修改或者删除
        /// </summary>
        /// <param name="strXml">标准xml</param>
        /// <returns></returns>
        public static string ClassEditOrDel(string strXml)
        {
            /// 调用统一的标准操作型xml的处理方法
            string strRetXml = Operation.dealWithXml(strXml);

            DicCache.getInstance().createDicFile("DIC_STUCLASS", "SELECT CLASSID,CLASSNAME FROM STUCLASS ORDER BY CLASSID");

            return(strRetXml);
        }
Example #3
0
        public static string ExpExcel(string path)
        {
            ReturnDoc obj_ReturnDoc = new ReturnDoc();

            try
            {
                Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

                Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;
                Microsoft.Office.Interop.Excel.Workbook  workbook  = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
                Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];//取得sheet1

                worksheet.Cells[1, 1] = "管道名称";


                // 数据查询

                OleDbDataReader rst = null;
                string          ret = CommonQuery.qryRst("select * from PIPELINE", ref rst);
                Int16           i   = 2;

                DicCache dic = DicCache.getInstance();

                if (ret.Equals("0"))
                {
                    while (rst.Read())
                    {
                        worksheet.Cells[i, 1] = rst["DATA1"].ToString();
                        i++;
                    }

                    rst.Close();
                }


                string sPath    = path;
                string filename = "海底管道数据导出.xls";

                workbook.Saved = true;
                workbook.SaveCopyAs(sPath + filename);

                xlApp.Quit();


                obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS);
                obj_ReturnDoc.setFuncErrorInfo(filename);
            }
            catch (Exception e)
            {
                obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR);
                obj_ReturnDoc.setFuncErrorInfo(e.Message);
            }

            return(obj_ReturnDoc.getXml());
        }
Example #4
0
 /// <summary>
 /// 生成字典文件
 /// </summary>
 /// <param name="strDicName">字典名称</param>
 /// <returns>是否成功</returns>
 public static void CreateDicFile(string strDicName)
 {
     try
     {
         DicCache.getInstance().createDicFile(strDicName);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #5
0
        /// <summary>
        /// 添加新的班级,并重新生成字典文件
        /// </summary>
        /// <param name="strXml"></param>
        /// <returns></returns>
        public static string ClassAdd(string strXml)
        {
            XmlDocument obj_Doc = XmlFun.CreateNewDoc(strXml);

            // 分配班级编码
            string strClassID = NumAssign.assignID_B("100003", "A");

            XmlFun.setNodeValue(obj_Doc, "//CLASSID", strClassID);

            string op_xml = obj_Doc.InnerXml;

            /// 调用统一的标准操作型xml的处理方法
            string strRetXml = Operation.dealWithXml(op_xml);

            DicCache.getInstance().createDicFile("DIC_STUCLASS", "SELECT CLASSID,CLASSNAME FROM STUCLASS ORDER BY CLASSID");

            return(strRetXml);
        }
Example #6
0
        /// <summary>
        /// 自动过期
        /// </summary>
        private static void TaskCacheExpired()
        {
            Task.Run(() => {
                while (true)
                {
                    try
                    {
                        $"自动过期线程开始运行!".ConsoleWriteLine();

                        ListDelKeys = new List <string>();
                        foreach (var item in DicCache.Keys)
                        {
                            bool flag = DicCache[item].ExpiredTime > DateTime.Now;
                            if (flag)
                            {
                                ListDelKeys.Add(item);
                            }
                        }

                        ListDelKeys.ForEach(key => {
                            bool flag = DicCache.TryRemove(key, out MDicValue tempModel);
                            if (!flag)
                            {
                                $"从字典中删除键:{key}失败!TryRemove的返回值为:{tempModel.SerializeObject()}".ConsoleWriteLineWithErrLog();
                            }
                        });


                        ListDelKeys = null;
                    }
                    catch (Exception ex)
                    {
                        $"自动过期线程发生异常:{ex.Message}".ConsoleWriteLineWithErrLog();
                    }
                    finally
                    {
                        SleepSecond = SleepSecond == 0 ? 15 * 60 : SleepSecond;
                        $"自动过期线程开始休眠,休眠时间:{SleepSecond}秒,下次运行时间:{DateTime.Now.AddSeconds(SleepSecond)}".ConsoleWriteLine();
                        Thread.Sleep(SleepSecond * 1000);
                    }
                }
            });
        }
Example #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // 设置字典路径
     DicCache.getInstance().setDicPath(Server.MapPath("dic"));
 }
Example #8
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="key">键</param>
 /// <returns>bool</returns>
 public static bool Del(string key)
 {
     return(DicCache.TryRemove(key, out MDicValue value));
 }
Example #9
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="key">键</param>
 /// <param name="value">值</param>
 /// <returns>bool</returns>
 public static bool Add(string key, MDicValue value)
 {
     return(DicCache.TryAdd(key, value));
 }
Example #10
0
 /// <summary>
 /// 判断是否存在key
 /// </summary>
 /// <param name="key"></param>
 public static bool Exsit(string key)
 {
     return(DicCache.ContainsKey(key));
 }
Example #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string saveFoler = Server.MapPath("upload_files/");
            string savePath, fileName, newName = "";
            //遍历File表单元素
            for (int iFile = 0; iFile < Request.Files.Count; iFile++)
            {
                HttpPostedFile postedFile = Request.Files[iFile];
                fileName = Path.GetFileName(postedFile.FileName);
                if (fileName != "")
                {
                    string fileType = fileName.Substring(fileName.LastIndexOf("."));
                    if (!fileType.ToLower().Equals(".xls"))
                    {
                        throw (new Exception("文件类型错误"));
                    }
                    // newName = "dbtask001" + fileType;
                    newName  = Guid.NewGuid().ToString("N") + fileType;
                    savePath = saveFoler + newName;
                    //检查是否在服务器上已经存在用户上传的同名文件
                    if (File.Exists(savePath))
                    {
                        File.Delete(savePath);
                    }
                    postedFile.SaveAs(savePath);

                    // 文件保存完成了,现在开始分析Excel 导入到数据库中

                    string          strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + savePath + "; Extended Properties=Excel 8.0;";
                    OleDbConnection oleConn = new OleDbConnection(strConn);
                    oleConn.Open();
                    OleDbCommand    mdo          = new OleDbCommand("select * from  [sheet1$]", oleConn);
                    Boolean         rsOpen       = false;
                    OleDbDataReader rst          = mdo.ExecuteReader();
                    DicCache        obj_DicCache = DicCache.getInstance();
                    DataStorage     obj_Storage  = new DataStorage();

                    while (rst.Read())
                    {
                        //string dbdate = rst["打标日期"].ToString().Trim();

                        //string customid = obj_DicCache.getCode("DIC_CUSTOM", rst["客户"].ToString().Trim());

                        //if(dbdate != "" && customid != "")
                        //{

                        //string strtaskid = NumAssign.assignID_B("200001", General.curYear2() + General.curMonth());
                        //string strtasksubid = NumAssign.assignID_B("200005", customid + General.cDateStr(dbdate));
                        string PIPEID = NumAssign.assignID_B("100004", General.curYear2() + General.curMonth() + General.curDay());
                        string DATA1  = rst["管道名称"].ToString().Trim();
                        string sql    = "insert into PIPELINE(PIPEID,DATA1) VALUES('" + PIPEID + "','" + DATA1 + "')";

                        //string sql = "insert into BARCODETASK (TASKID,DQ,CUSTOMID,DBDATE,WRITETIME,TASKSUBID,SELLNO,XS,JB,DCTYPE,MODEL,ZPLX,CDZH,DBJDM,ZY,GROUPNUM,ORDNUM,STATUS,BAK) values ('" + strtaskid
                        //             + "','" + obj_DicCache.getCode("DIC_DQ", rst["地区"].ToString().Trim()) + "','"
                        //             + customid + "'," + General.formatDate(dbdate) + "," + General.formatDate(rst["任务下达日期"].ToString().Trim()) + ",'" + strtasksubid + "','"
                        //             + rst["销售单据号"].ToString().Trim() + "'," + rst["系数"].ToString().Trim() + ",'"
                        //             + obj_DicCache.getCode("DIC_JB", rst["极板"].ToString().Trim()) + "','"
                        //             + obj_DicCache.getCode("DIC_DCTYPE", rst["电池类型"].ToString().Trim()) + "','"
                        //             + obj_DicCache.getCode("DIC_MODEL", rst["型号"].ToString().Trim()) + "','"
                        //             + obj_DicCache.getCode("DIC_ZPLX", rst["装配类型"].ToString().Trim()) + "','"
                        //             + obj_DicCache.getCode("DIC_CDZH", rst["充电组号"].ToString().Trim()) + "','"
                        //             + obj_DicCache.getCode("DIC_DBJDM", rst["打码机器"].ToString().Trim()) + "','"
                        //             + obj_DicCache.getCode("DIC_ZY", rst["专用"].ToString().Trim()) + "'," + rst["组数"].ToString().Trim() + ",0,'0','"
                        //             + rst["备注"].ToString().Trim() + "')";
                        obj_Storage.addSQL(sql);
                        //}

                        rsOpen = true;
                    }

                    /// 执行
                    string str_Return = obj_Storage.runSQL();

                    if (!General.empty(str_Return))
                    {
                        throw (new Exception(str_Return));
                    }

                    if (rsOpen)
                    {
                        rst.Close();
                    }

                    oleConn.Close();
                }
            }

            jSONString = "{success:true,message:'上传完成!',filename:'" + newName + "'}";
        }//try
        catch (Exception ex)
        {
            jSONString = "{success:false,message:'" + ex.Message.Replace('\'', '"') + "'}";
        }//catch
        Response.Write(jSONString);
        Response.Flush();
    }
Example #12
0
        public static string getQueryXml(OleDbDataReader rst,
                                         string[] strDicFieldList,
                                         string[] strDicNameList,
                                         string[] strDateFieldList,
                                         int int_TotalRecords,
                                         int int_TotalPages,
                                         Boolean blnDicInSv,
                                         string strListName)
        {
            strListName = strListName == null ? Common.XDOC_ROW : strListName;

            ReturnDoc docReturn = new ReturnDoc();

            try
            {
                if (docReturn.getQueryInfo(rst, strListName))
                {
                    XmlDocument doc      = docReturn.getDocument();
                    XmlNodeList nodeList = doc.SelectNodes(Common.BAR2 + strListName);

                    for (int k = 0; k < nodeList.Count; k++)
                    {
                        XmlNode node = (XmlElement)nodeList.Item(k);

                        XmlElement node_Temp;
                        /// 处理字典的翻译
                        DicCache obj_DicCache = DicCache.getInstance();
                        if (strDicFieldList != null)
                        {
                            for (int i = 0; i < strDicFieldList.Length; i++)
                            {
                                node_Temp = (XmlElement)node.SelectSingleNode(strDicFieldList[i]);
                                string str_Text = node_Temp.InnerText;

                                if (General.empty(str_Text))
                                {
                                    continue;
                                }

                                string str_SV = obj_DicCache.getText(strDicNameList[i], str_Text);


                                if (!blnDicInSv)
                                {
                                    if (str_SV != null)
                                    {
                                        node_Temp.InnerText = str_SV;
                                    }
                                }
                                else
                                {
                                    if (str_SV != null)
                                    {
                                        node_Temp.SetAttribute(Common.XML_PROP_SV, str_SV);
                                    }
                                }
                            }
                        }

                        /// 处理日期类型的字段
                        if (strDateFieldList != null)
                        {
                            for (int i = 0; i < strDateFieldList.Length; i++)
                            {
                                node_Temp = (XmlElement)node.SelectSingleNode(strDateFieldList[i]);
                                string str_Text = node_Temp.InnerText;

                                if (General.empty(str_Text))
                                {
                                    continue;
                                }

                                string str_SV = General.cDateStr(str_Text);
                                str_Text            = General.strToDate(str_SV);
                                node_Temp.InnerText = str_Text;

                                if (blnDicInSv)
                                {
                                    if (str_SV != null)
                                    {
                                        node_Temp.SetAttribute(Common.XML_PROP_SV, str_SV);
                                    }
                                }
                            }
                        }
                    }
                    docReturn.addErrorResult(Common.RT_QUERY_SUCCESS);
                }
                else
                {
                    docReturn.addErrorResult(Common.RT_QUERY_NOTHING);
                }
                docReturn.addPropToQueryInfo(Common.XML_PROP_TOTALPAGES, int_TotalPages.ToString());
                docReturn.addPropToQueryInfo(Common.XML_PROP_RECORDS, int_TotalRecords.ToString());
            }
            catch (Exception e)
            {
            }
            return(docReturn.getXml());
        }