private ExtensionContainer()
        {
            ExtensionContainer.Extensions.Clear();
            HiConfiguration config        = HiContext.Current.Config;
            XmlNode         configSection = config.GetConfigSection("Ecdev/Extensions");

            if (configSection != null)
            {
                foreach (XmlNode xmlNode in configSection.ChildNodes)
                {
                    if (xmlNode.NodeType != XmlNodeType.Comment && xmlNode.Name.Equals("add"))
                    {
                        string       value        = xmlNode.Attributes["name"].Value;
                        string       value2       = xmlNode.Attributes["type"].Value;
                        XmlAttribute xmlAttribute = xmlNode.Attributes["enabled"];
                        if (xmlAttribute == null || !(xmlAttribute.Value == "false"))
                        {
                            System.Type type = System.Type.GetType(value2);
                            if (type == null)
                            {
                                throw new System.Exception(value2 + " does not exist");
                            }
                            IExtension extension = System.Activator.CreateInstance(type) as IExtension;
                            if (extension == null)
                            {
                                throw new System.Exception(value2 + " does not implement IExtension or is not configured correctly");
                            }
                            extension.Init();
                            ExtensionContainer.Extensions.Add(value, extension);
                        }
                    }
                }
            }
        }
Exemple #2
0
 public void Start()
 {
     Interlocked.Increment(ref Jobs._instancesOfParent);
     lock (this.jobList.SyncRoot)
     {
         if (this.jobList.Count == 0)
         {
             HiConfiguration config        = HiConfiguration.GetConfig();
             XmlNode         configSection = config.GetConfigSection("Ecdev/Jobs");
             bool            flag2         = true;
             XmlAttribute    xmlAttribute  = configSection.Attributes["singleThread"];
             if (xmlAttribute != null && !string.IsNullOrEmpty(xmlAttribute.Value) && string.Compare(xmlAttribute.Value, "false", true, CultureInfo.InvariantCulture) == 0)
             {
                 flag2 = false;
             }
             XmlAttribute xmlAttribute2 = configSection.Attributes["minutes"];
             if (xmlAttribute2 != null && !string.IsNullOrEmpty(xmlAttribute2.Value))
             {
                 int num = 1;
                 if (int.TryParse(xmlAttribute2.Value, out num))
                 {
                     this.Interval = num * 60000;
                 }
             }
             foreach (XmlNode xmlNode in configSection.ChildNodes)
             {
                 if (configSection.NodeType != XmlNodeType.Comment && xmlNode.NodeType != XmlNodeType.Comment)
                 {
                     XmlAttribute xmlAttribute3 = xmlNode.Attributes["type"];
                     XmlAttribute xmlAttribute4 = xmlNode.Attributes["name"];
                     Type         type          = Type.GetType(xmlAttribute3.Value);
                     if (type != null)
                     {
                         if (!this.jobList.Contains(xmlAttribute4.Value))
                         {
                             Job job = new Job(type, xmlNode);
                             if (flag2 && job.SingleThreaded)
                             {
                                 job.InitializeTimer();
                             }
                             else
                             {
                                 this.jobList[xmlAttribute4.Value] = job;
                             }
                         }
                     }
                 }
             }
             if (this.jobList.Count > 0)
             {
                 this.singleTimer = new Timer(new TimerCallback(this.call_back), null, this.Interval, this.Interval);
             }
         }
     }
 }
Exemple #3
0
        public void GetPO_Status(System.Web.HttpContext context)
        {
            string status = context.Request["status"].ToLower();
            string id     = context.Request["id"].ToLower();
            string Remark = context.Request["Remark"];

            string UserId   = context.Request["UserId"].ToLower();
            string Username = context.Request["Username"];

            if (!string.IsNullOrEmpty(status) && !string.IsNullOrEmpty(id))
            {
                //招商权限(确认、取消确认)POZS和关务权限(除确认外其他)POGW
                //确认和取消确认只有招商有权限
                if ((status == "0" || status == "1") && !CheckPrivilegeReturn(Username, Privilege.POZS))
                {
                    this.message = "{\"success\":\"NO\",\"MSG\":\"您无权操作,请联系管理员!\"}";
                    return;
                }

                if (status != "0" && status != "1" && !CheckPrivilegeReturn(Username, Privilege.POGW))
                {
                    this.message = "{\"success\":\"NO\",\"MSG\":\"您无权操作,请联系管理员!\"}";
                    return;
                }

                //申报、确认、删除、编辑在页面判断是否是自己的
                if (status == "-1")
                {
                    Remark = string.Format("{0}_{1}退回,时间:{2}", UserId, Username, DateTime.Now);
                }

                if (status == "0")
                {
                    Remark = string.Format("{0}_{1}取消确认,时间:{2}", UserId, Username, DateTime.Now);
                }

                //确认时必须要有明细
                if (status == "1" && !PurchaseOrderHelper.IsExistsPOItem(id))
                {
                    this.message = "{\"success\":\"NO\",\"MSG\":\"确认失败,请先添加采购订单明细!\"}";
                    return;
                }

                //如果是申报成功先调用WMS接口,成功后再修改
                if (status == "7")
                {
                    //1.获取发送需要的数据
                    DataSet ds = PurchaseOrderHelper.GetPurchaseOrderAndItem("po.id=" + id);
                    if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        ErrorLog.Write("执行了putASNData->PurchaseOrderHelper.GetPurchaseOrderAndItem返回查询结果:" + ds.Tables[0].Rows.Count);
                        //构造数据
                        string skuData = this.CreatePOData(ds.Tables[0]);
                        skuData = skuData.Replace("\n", "").Replace("\t", "").Replace("\r", "").Replace("+", "+");

                        //配置获取
                        HiConfiguration config        = HiConfiguration.GetConfig();
                        XmlNode         configSection = config.GetConfigSection("Ecdev/Jobs");
                        XmlNode         configjob     = configSection.SelectSingleNode("job[@name='OrderSendJob']");

                        string appkey     = configjob.Attributes["appkey"].InnerText;            // "test";//验签KEY
                        string appSecret  = configjob.Attributes["appSecret"].InnerText;         //"1234567890";//秘钥存配置
                        string customerid = configjob.Attributes["client_customerid"].InnerText; // "XJW";//client_customerid
                        string client_db  = configjob.Attributes["client_db"].InnerText;         // "WH01";
                        string apptoken   = configjob.Attributes["apptoken"].InnerText;          //"80AC1A3F-F949-492C-A024-7044B28C8025";
                        string url        = configjob.Attributes["apiurl"].InnerText;            //"http://192.168.1.120:8090/datahubWeb/FLUXWMSAPI/XJW";//apiurl

                        //生成验签值
                        string tempdata     = appSecret + skuData + appSecret;
                        string md5tempdata  = WMSHelper.MD5(tempdata);
                        string basetempdata = WMSHelper.EncodingString(md5tempdata.ToLower(), System.Text.Encoding.UTF8);
                        string sign         = System.Web.HttpUtility.UrlEncode(basetempdata.ToUpper(), System.Text.Encoding.UTF8);
                        //时间戳
                        string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//YYYY-MM-DD HH:MM:SS
                        string postData  = "method=putASNData&client_customerid=" + customerid + "&client_db=" + client_db + "&messageid=ASN&apptoken=" + apptoken + "&appkey=" + appkey + "&sign=" + sign + "&timestamp=" + timestamp;

                        //记录发送数据日志
                        ErrorLog.Write("执行了putASNData->发送数据:postData=" + postData + "&data=" + skuData);
                        WMSHelper.SaveLog("putASNData", "postData=" + postData + "&data=" + skuData, "调用方法", "info", "out");

                        skuData = System.Web.HttpUtility.UrlEncode(skuData);
                        //发送并接收回传数据
                        string sendResult = WMSHelper.PostData(url, postData + "&data=" + skuData);
                        string tempResult = System.Web.HttpUtility.UrlDecode(sendResult);
                        //保存接收消息
                        ErrorLog.Write("执行了putASNData->接收WMS消息:" + tempResult + "\n");
                        WMSHelper.SaveLog("putASNData", "", "返回结果:" + tempResult, "info", "in");

                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.LoadXml(tempResult);
                        XmlNode node     = xmlDocument.SelectSingleNode("Response/return/returnCode");
                        XmlNode nodeFlag = xmlDocument.SelectSingleNode("Response/return/returnFlag");
                        XmlNode nodeDesc = xmlDocument.SelectSingleNode("Response/return/returnDesc");
                        if (node.InnerText != "0000")
                        {
                            //推送失败
                            this.message = "{\"success\":\"NO\",\"MSG\":\"采购订单传送WMS失败:" + nodeDesc.InnerText + "\"}";
                            return;
                        }
                    }
                    else
                    {
                        this.message = "{\"success\":\"NO\",\"MSG\":\"获取采购订单数据失败\"}";
                        return;
                    }
                }
                //执行更改
                if (PurchaseOrderHelper.SetPOStatus(id, status, Remark, int.Parse(UserId), Username))
                {
                    this.message = "{\"success\":\"YES\",\"MSG\":\"操作成功\"}";
                }
                else
                {
                    this.message = "{\"success\":\"NO\",\"MSG\":\"操作失败,请检查您是否有权限,如无问题请刷新后重试。\"}";
                }
            }
            else
            {
                this.message = "{\"success\":\"NO\",\"MSG\":\"参数获取失败\"}";
            }
        }