Exemple #1
0
        public void SynchroDataTo(Context ctx, SynchroDataType dataType, SynchroDirection direction)
        {
            HttpResponseResult result = null;

            try
            {
                if (direction == SynchroDirection.ToK3)
                {
                    result = SynchroDataHelper.SynchroDataToK3(ctx, dataType);
                }
                if (direction == SynchroDirection.ToHC)
                {
                    result = SynchroDataHelper.SynchroDataToHC(ctx, dataType);
                }
                if (result != null)
                {
                    if (result.Success)
                    {
                        this.View.ShowErrMessage("", string.Format("同步{0}至{1}成功!", LogUtils.GetDataSourceTypeDesc(dataType), direction.ToString()) + result.Message, Kingdee.BOS.Core.DynamicForm.MessageBoxType.Error);
                    }
                    else
                    {
                        this.View.ShowErrMessage("", string.Format("同步{0}至{1}失败!", LogUtils.GetDataSourceTypeDesc(dataType), direction.ToString()) + result.Message, Kingdee.BOS.Core.DynamicForm.MessageBoxType.Error);
                    }
                }
                else
                {
                    this.View.ShowErrMessage("", string.Format("同步{0}至{1}失败!", LogUtils.GetDataSourceTypeDesc(dataType), direction.ToString()), Kingdee.BOS.Core.DynamicForm.MessageBoxType.Error);
                }
            }
            catch (Exception ex)
            {
                this.View.ShowErrMessage(ex.ToString(), string.Format("同步{0}至{1}失败!", LogUtils.GetDataSourceTypeDesc(dataType), direction.ToString()), Kingdee.BOS.Core.DynamicForm.MessageBoxType.Error);
            }
        }
Exemple #2
0
        /// <summary>
        /// 单据批量作废
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="dataType"></param>
        /// <param name="formId"></param>
        /// <param name="numbers"></param>
        /// <param name="pkIds"></param>
        /// <returns></returns>
        public static HttpResponseResult InvokeBatchCancel(Context ctx, SynchroDataType dataType, string formId, IEnumerable <string> numbers = null, IEnumerable <int> pkIds = null)
        {
            HttpResponseResult response = default(HttpResponseResult);
            string             ret      = default(string);

            K3CloudApiClient client = null;

            DataBaseConst.K3CloudContext = ctx;

            client = new K3CloudApiClient(DataBaseConst.CurrentK3CloudURL);

            // 登陆成功
            if (Login(ctx, client))
            {
                if (numbers != null && numbers.Count() > 0)
                {
                    ret = client.ExcuteOperation(formId, "Cancel", "{\"CreateOrgId\":\"0\",\"Numbers\":[" + FormatFNumber(numbers) + "],\"Ids\":\"\"}");
                }
                if (pkIds != null && pkIds.Count() > 0)
                {
                    ret = client.ExcuteOperation(formId, "Cancel", "{\"CreateOrgId\":\"0\",\"Numbers\":[],\"Ids\":\"" + FormatFNumber(pkIds) + "\"}");
                }
                if (!string.IsNullOrEmpty(ret))
                {
                    response = Response(ctx, dataType, SynOperationType.DELETE, ret);
                }
            }

            return(response);
        }
Exemple #3
0
        /// <summary>
        /// 批量下推
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="dataType"></param>
        /// <param name="formId"></param>
        /// <param name="numbers"></param>
        /// <param name="pkIds"></param>
        /// <returns></returns>
        public static HttpResponseResult InvokeBatchPush(Context ctx, SynchroDataType dataType, string formId, IEnumerable <string> numbers = null, IEnumerable <int> pkIds = null)
        {
            HttpResponseResult response = default(HttpResponseResult);
            string             ret      = default(string);

            K3CloudApiClient client = null;

            DataBaseConst.K3CloudContext = ctx;

            client = new K3CloudApiClient(DataBaseConst.CurrentK3CloudURL);

            // 登陆成功
            if (Login(ctx, client))
            {
                if (numbers != null && numbers.Count() > 0)
                {
                    ret = client.Push("SAL_BATCHADJUSTPRICE", "{\"Ids\":\"\",\"Numbers\":[],\"EntryIds\":\"\",\"RuleId\":\"\",\"TargetBillTypeId\":\"\",\"TargetOrgId\":0,\"TargetFormId\":\"\",\"IsEnableDefaultRule\":\"false\",\"IsDraftWhenSaveFail\":\"false\",\"CustomParams\":{}}");
                }
                if (pkIds != null && pkIds.Count() > 0)
                {
                    ret = client.ExcuteOperation(formId, "Cancel", "{\"CreateOrgId\":\"0\",\"Numbers\":[],\"Ids\":\"" + FormatFNumber(pkIds) + "\"}");
                }
                if (!string.IsNullOrEmpty(ret))
                {
                    response = Response(ctx, dataType, SynOperationType.DELETE, ret);
                }
            }

            return(response);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        /// <param name="postData"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        public HttpResponseResult HttpPost(string url, string postData, IDictionary <string, string> headers)
        {
            HttpResponseResult result = null;
            Uri uri = null;

            if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri))
            {
                var    resEncode = DefaultEncode;// DomainSetting.FindDomainRule(httpRequest.RequestUri.Host).Encode;
                byte[] buffer    = null;

                var httpRequest = CreateHttpRequest(uri, headers);
                httpRequest.Method = HttpMethod.POST.ToString();
                //httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                httpRequest.ContentType = "application/json; charset=utf-8";
                if (null != postData)
                {
                    buffer = Encoding.GetEncoding(resEncode).GetBytes(postData);
                    httpRequest.ContentLength = buffer.Length;

                    using (var postStream = httpRequest.GetRequestStream())
                    {
                        postStream.Write(buffer, 0, buffer.Length);
                    }
                }

                result = SendRequest(httpRequest);
            }

            return(result);
        }
Exemple #5
0
        /// <summary>
        /// 单据批量保存
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="dataType"></param>
        /// <param name="formId"></param>
        /// <param name="json"></param>
        /// <returns></returns>
        public static HttpResponseResult InvokeBatchSave(Context ctx, SynchroDataType dataType, string formId, string json)
        {
            HttpResponseResult response = default(HttpResponseResult);
            string             ret      = default(string);
            K3CloudApiClient   client   = null;

            DataBaseConst.K3CloudContext = ctx;

            lock (SaveLock)
            {
                client = new K3CloudApiClient(DataBaseConst.CurrentK3CloudURL);

                if (Login(ctx, client))
                {
                    ret = client.BatchSave(formId, json);
                }
                else
                {
                    response         = new HttpResponseResult();
                    response.Success = false;
                    response.Message = "登陆账号或密码错误!";
                }
                if (!string.IsNullOrEmpty(ret))
                {
                    response = Response(ctx, dataType, SynOperationType.SAVE, ret, json);
                }
            }

            return(response);
        }
        public override IEnumerable <AbsSynchroDataInfo> GetK3Datas(Context ctx, List <DynamicObject> objects, ref HttpResponseResult result)
        {
            List <AbsDataInfo> reFunds = null;
            AbsDataInfo        reFund  = null;

            result         = new HttpResponseResult();
            result.Success = true;

            if (objects != null && objects.Count > 0)
            {
                reFunds = new List <AbsDataInfo>();

                foreach (var obj in objects)
                {
                    if (obj != null)
                    {
                        DynamicObject rMethod      = obj["F_HS_RefundMethod"] as DynamicObject;
                        string        reFundMethod = SQLUtils.GetFieldValue(rMethod, "FNumber");

                        string document = SQLUtils.GetFieldValue(obj, "DOCUMENTSTATUS");

                        if (!string.IsNullOrWhiteSpace(reFundMethod) && !string.IsNullOrWhiteSpace(document))
                        {
                            if (reFundMethod.CompareTo("TKDKHYE") == 0 && document.CompareTo("C") == 0)
                            {
                                reFund = new AbsDataInfo();

                                reFund.FDate   = SQLUtils.GetFieldValue(obj, "DATE");
                                reFund.FBillNo = SQLUtils.GetFieldValue(obj, "BILLNo");

                                DynamicObject cust = obj["F_HS_B2CCustId"] as DynamicObject;
                                reFund.F_HS_B2CCustId = SQLUtils.GetFieldValue(cust, "Number");

                                DynamicObject curr = obj["SETTLECUR"] as DynamicObject;
                                reFund.FSettleCurrId = SQLUtils.GetFieldValue(curr, "Number");

                                reFund.F_HS_RateToUSA          = Convert.ToDecimal(SQLUtils.GetFieldValue(obj, "F_HS_RateToUSA"));
                                reFund.F_HS_BalanceRechargeUSD = Convert.ToDecimal(SQLUtils.GetFieldValue(obj, "REALREFUNDAMOUNTFOR"));

                                DynamicObject org = obj["SETTLEORGID"] as DynamicObject;
                                reFund.FSaleOrgId = SQLUtils.GetFieldValue(org, "Number");

                                DynamicObject dept = obj["SALEDEPTID"] as DynamicObject;
                                reFund.FSaleDeptId = SQLUtils.GetFieldValue(dept, "Number");

                                DynamicObject seller = obj["SALEERID"] as DynamicObject;
                                reFund.FSalerId = SQLUtils.GetFieldValue(seller, "Number");
                                reFund.F_HS_BalanceReceivableNo = SQLUtils.GetFieldValue(obj, "F_HS_BalanceReceivableNo");
                                DynamicObjectCollection entry = obj["REFUNDBILLENTRY"] as DynamicObjectCollection;
                                reFund.FSettleTypeId = GetSettleType(entry);

                                reFunds.Add(reFund);
                            }
                        }
                    }
                }
            }

            return(reFunds);
        }
        /// <summary>
        /// 获取销售订单发货状态
        /// </summary>
        /// <returns></returns>
        //public abstract string GetShipStatus(Context ctx);
        /// <summary>
        /// 向HC网站发送请求
        /// </summary>
        public virtual List <HttpResponseResult> SendRequest(Context ctx, List <K3SalOrderInfo> orders, string requestType)
        {
            List <HttpResponseResult> results = null;
            HttpResponseResult        result  = null;

            try
            {
                HttpClient_ client = new HttpClient_();

                if (ctx.DBId.CompareTo(DataBaseConst.K3CloudDbId) == 0)
                {
                    client.Url = "https://admin2.healthcabin.net/Staff_AdminIT/response.php?t_method=updateOrderStatus_api";
                }
                else
                {
                    client.Url = "https://admin2.healthcabin.net/Staff_AdminIT/response.php?t_method=updateOrderStatus_api";
                }

                client.Content = string.Concat("&ERP=", BuildRequestParams(ctx, orders, requestType).ToString());
                string response = client.PostData();
                return(GetResponse(ctx, response));
            }
            catch (Exception ex)
            {
                results        = new List <HttpResponseResult>();
                result         = new HttpResponseResult();
                result.Success = false;
                result.Message = "请求服务器发生异常:" + System.Environment.NewLine + ex.Message + System.Environment.NewLine + ex.StackTrace;

                results.Add(result);
                LogUtils.WriteSynchroLog(ctx, SynchroDataType.SaleOrder, "请求服务器发生异常:" + System.Environment.NewLine + ex.Message + System.Environment.NewLine + ex.StackTrace);

                return(results);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="httpMethod"></param>
        /// <param name="url"></param>
        /// <param name="jsonData"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        public HttpResponseResult HttpJson(HttpMethod httpMethod, string url, string jsonData, IDictionary <string, string> headers)
        {
            HttpResponseResult result = null;
            Uri uri = null;

            if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri))
            {
                var    resEncode = DefaultEncode;// DomainSetting.FindDomainRule(httpRequest.RequestUri.Host).Encode;
                byte[] buffer    = Encoding.GetEncoding(resEncode).GetBytes(jsonData);

                var httpRequest = CreateHttpRequest(uri, headers);
                httpRequest.Method        = httpMethod.ToString();
                httpRequest.ContentType   = "application/json";
                httpRequest.ContentLength = buffer.Length;

                using (var postStream = httpRequest.GetRequestStream())
                {
                    postStream.Write(buffer, 0, buffer.Length);
                }

                result = SendRequest(httpRequest);
            }

            return(result);
        }
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            HttpResponseResult result = null;
            var task = Task.Factory.StartNew(() =>
            {
                if (e.DataEntitys == null)
                {
                    return;
                }
                List <DynamicObject> dataEntitys = e.DataEntitys.ToList();

                if (dataEntitys == null || dataEntitys.Count <= 0)
                {
                    return;
                }

                this.DyamicObjects = e.DataEntitys.ToList();
                SynchroK3DataToWebSite(this.Context);
                IEnumerable <AbsSynchroDataInfo> datas = GetK3Datas(this.Context, this.DyamicObjects, ref result);

                if (datas != null && datas.Count() > 0)
                {
                    LogHelper.WriteSynSalOrderStatus(this.Context, datas.Select(o => (K3SalOrderStatusInfo)o).ToList());
                }
            }
                                             );
        }
Exemple #10
0
        /// <summary>
        /// 下载验证码
        /// </summary>
        public static bool DownloadImage()
        {
            HttpResponseResult ResponseResult = HttpMethods.Get(UrlDefine.LoginUrl, new System.Net.CookieContainer(), Encoding.UTF8);

            if (ResponseResult.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string[] str       = ResponseResult.ContentData.ToString().Split(';');
                string   ImageCode = str[1].Substring(str[1].IndexOf("\"") + 1, str[1].Length - str[1].IndexOf("\"") - 2);
                UrlDefine.Tickets    = ImageCode;
                CommonDefine.Cookies = HttpMethods.getCookie(UrlDefine.RootUrl);
                ResponseResult       = HttpMethods.GetFile(UrlDefine.LoginUrlWithToken + ImageCode, "Check.jpg", new System.Net.CookieContainer());
                if (ResponseResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    LogWriter.Write("下载微信登录二维码成功...", LogPathDefine.WeChatLogPath);
                    return(true);
                }
                else
                {
                    LogWriter.Write("获取微信登录二维码失败...", LogPathDefine.WeChatErrorLogPath);
                    LogWriter.Write(string.Format("当前返回状态码是{0},返回信息是{1}", ResponseResult.StatusCode.ToString(), ResponseResult.ReturnMsg), LogPathDefine.WeChatErrorLogPath);
                    return(false);
                }
            }
            else
            {
                //请求出现问题
                LogWriter.Write("访问微信登官网失败...", LogPathDefine.WeChatErrorLogPath);
                LogWriter.Write(string.Format("当前返回状态码是{0},返回信息是{1}", ResponseResult.StatusCode.ToString(), ResponseResult.ReturnMsg), LogPathDefine.WeChatErrorLogPath);
                return(false);
            }
        }
        public override void EndOperationTransaction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EndOperationTransactionArgs e)
        {
            base.EndOperationTransaction(e);

            List <AbsSynchroDataInfo> temp = new List <AbsSynchroDataInfo>();

            if (e.DataEntitys == null)
            {
                return;
            }
            List <DynamicObject> dataEntitys = e.DataEntitys.ToList();
            HttpResponseResult   result      = new HttpResponseResult();

            if (dataEntitys == null || dataEntitys.Count <= 0)
            {
                return;
            }

            List <AbsSynchroDataInfo> datas = GetK3Datas(this.Context, dataEntitys, ref result).ToList();

            if (datas != null && datas.Count > 0)
            {
                if (temp.All(a => datas.Any(b => a.Equals(b))))
                {
                    temp = temp.Concat(datas).ToList();

                    if (IsConnectSuccess(this.Context))
                    {
                        this.DyamicObjects = e.DataEntitys.ToList();
                        SynchroK3DataToWebSite(this.Context);
                        LogHelper.WriteSynSalOrderStatus(this.Context, temp.Select(o => (K3SalOrderStatusInfo)o).ToList());
                    }
                }
            }
        }
        public override void EndOperationTransaction(EndOperationTransactionArgs e)
        {
            base.EndOperationTransaction(e);

            List <DynamicObject> objects = e.DataEntitys.ToList();

            result = OperateAfterAudit(this.Context, objects);
        }
Exemple #13
0
        HttpResponseResult SendRequest(HttpWebRequest httpRequest)
        {
            HttpWebResponse httpResponse = null;
            var             status       = WebExceptionStatus.UnknownError;

            try
            {
                httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                status       = WebExceptionStatus.Success;
            }
            catch (WebException ex)
            {
                // only handle protocol errors that have valid responses
                if (ex.Response == null)
                {
                    Console.WriteLine("err : {0}\t{1}", ex.Status, httpRequest.RequestUri.AbsoluteUri);
                    throw;
                }
                status       = ex.Status;
                httpResponse = (HttpWebResponse)ex.Response;
            }

            var result = new HttpResponseResult();

            result.Status       = status;
            result.ResourceType = GetHttpResourceType(httpResponse.ContentType);
            result.StatusCode   = httpResponse.StatusCode;
            result.ResponseUri  = httpResponse.ResponseUri.ToString();
            result.Redirected   = httpResponse.ResponseUri.Host != httpRequest.RequestUri.Host;

            if (status == WebExceptionStatus.Success && httpRequest.Method != HttpMethod.HEAD.ToString())
            {
                switch (result.ResourceType)
                {
                case HttpResourceType.Html:
                case HttpResourceType.Text:
                case HttpResourceType.Xml:
                case HttpResourceType.ApplicationFile:
                {
                    result.Content = GetContent(httpResponse);
                    break;
                }

                default:
                {
                    result.Stream = GetBytes(httpResponse);
                    break;
                }
                }
            }
            else
            {
                result.Content = GetContent(httpResponse);
                Console.WriteLine("HTTP ERROR >>>>>>>>>>>> {0}", result.Content);
            }

            return(result);
        }
Exemple #14
0
        private HttpResponseResult RequestServices(string json)
        {
            //if (!string.IsNullOrWhiteSpace(json))
            //{
            //    HttpClient http = new HttpClient() { IsProxy = true };

            //    http.Url = "http://localhost/K3Cloud/Services/SynchroServiceBus.asmx/SynchroData";
            //    http.Content = "&json=" + HttpUtility.UrlEncode(json, Encoding.UTF8);

            //    string ret = string.Empty;
            //    try
            //    {
            //        ret = http.PostData();
            //        return JsonConvert.DeserializeObject<HttpResponseResult>(ret);
            //    }
            //    catch (Exception ex)
            //    {
            //        HttpResponseResult result = new HttpResponseResult();
            //        result.Success = false;
            //        result.Message = ex.Message + Environment.NewLine + ex.StackTrace;

            //        return result;
            //    }
            //}

            try
            {
                string        Url       = "http://localhost/K3Cloud/Services/SynchroServiceBus.asmx";
                string        method    = "SynchroData";                                         //The method name
                string        postData  = "&json=" + HttpUtility.UrlEncode(json, Encoding.UTF8); //required parameter
                ASCIIEncoding encoding  = new ASCIIEncoding();
                byte[]        dataArray = Encoding.UTF8.GetBytes(postData);                      //Set coding specifications

                HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(Url + "/" + method); //Creating a Web service request
                request2.Method        = "Post";
                request2.ContentType   = "application/x-www-form-urlencoded";
                request2.ContentLength = dataArray.Length;

                Stream Writer = request2.GetRequestStream();  //Gets the Stream object used to write to the request data
                Writer.Write(dataArray, 0, dataArray.Length); //Writes parameter data to the request data stream
                Writer.Close();

                HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse();                        //Get the response
                StreamReader    stream2   = new StreamReader(response2.GetResponseStream(), Encoding.UTF8); //Get the response Stream
                string          result3   = stream2.ReadToEnd();
                stream2.Close();

                return(JsonConvert.DeserializeObject <HttpResponseResult>(result3));
            }
            catch (Exception ex)
            {
                HttpResponseResult result = new HttpResponseResult();
                result.Success = false;
                result.Message = ex.Message + Environment.NewLine + ex.StackTrace;

                return(result);
            }
        }
        /// <summary>
        /// 获取服务器响应请求操作的状态
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public virtual string GetOperateStatusDesc(HttpResponseResult result)
        {
            if (result != null)
            {
                return(result.Success ? "成功" : "失败");
            }

            return(null);
        }
        public HttpResponseResult AfterAllot(Context ctx)
        {
            HttpResponseResult    result = null;
            List <K3CustomerInfo> custs  = DownLoadCustomersByExcel(ctx);

            List <K3CustomerInfo> lstBatch = null;

            try
            {
                #region
                if (custs != null && custs.Count > 0)
                {
                    lstBatch = new List <K3CustomerInfo>();
                    if (custs.Count >= 500)
                    {
                        #region
                        for (int i = 0; i < custs.Count; i++)
                        {
                            lstBatch.Add(custs[i]);
                            if (i > 0 && (i + 1) % 500 == 0)
                            {
                                if (lstBatch != null && lstBatch.Count > 0)
                                {
                                    //result = AfterAllot(ctx, lstBatch);
                                    lstBatch.Clear();
                                }
                            }
                            else
                            {
                                if (i == custs.Count - 1)
                                {
                                    if (lstBatch != null && lstBatch.Count > 0)
                                    {
                                        //result = AfterAllot(ctx, lstBatch);
                                        lstBatch.Clear();
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        //result = AfterAllot(ctx, custs);
                        lstBatch.Clear();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogUtils.WriteSynchroLog(this.K3CloudContext, this.DataType, "分配操作出现异常,异常信息:" + ex.Message + System.Environment.NewLine + ex.StackTrace);
                AfterAllot(ctx);
            }

            return(result);
        }
Exemple #17
0
        public override IEnumerable <AbsSynchroDataInfo> GetK3Datas(Context ctx, List <DynamicObject> objects, ref HttpResponseResult result)
        {
            result         = new HttpResponseResult();
            result.Success = true;

            DynamicObjectCollection coll = SQLUtils.GetObjects(ctx, GetSql(ctx, objects));

            return(BuildSalOutStockBillInfo(coll));
        }
Exemple #18
0
        /// <summary>
        /// 获取物流细节
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="notices"></param>
        /// <returns></returns>
        public static Dictionary <string, T> GetLogisticsDetail <T>(Context ctx, List <DeliveryNotice> notices)
        {
            string messages             = "";
            Dictionary <string, T> dict = new Dictionary <string, T>();

            // Set this to true to process a COD shipment and print a COD return Label

            if (notices != null && notices.Count > 0)
            {
                foreach (var notice in notices)
                {
                    ProcessShipmentRequest request = CreateShipmentRequest(notice);

                    LogXML("DeliveryNoitceNo:" + notice.FBillNo + " Request ", request, typeof(ProcessShipmentRequest));

                    ShipService service = new ShipService();
                    if (usePropertyFile())
                    {
                        service.Url = getProperty("endpoint");
                    }
                    //
                    try
                    {
                        // Call the ship web service passing in a ProcessShipmentRequest and returning a ProcessShipmentReply
                        ProcessShipmentReply reply = service.processShipment(request);

                        LogXML("DeliveryNoitceNo:" + notice.FBillNo + " Reply ", reply, typeof(ProcessShipmentReply));
                        messages += GetNotifications(reply);

                        if ((reply.HighestSeverity != NotificationSeverityType.ERROR) && (reply.HighestSeverity != NotificationSeverityType.FAILURE))
                        {
                            notice.TraceEntry = GetShipmentReply(reply);
                            //LogXML(reply, typeof(ProcessShipmentReply));
                        }
                        RecordNotifications(ctx, reply);
                    }
                    catch (SoapException ex)
                    {
                        SynchroDataHelper.WriteSynchroLog(ctx, SynchroDataType.DeliveryNoticeBill, ex.Message + System.Environment.NewLine + ex.StackTrace);
                    }
                    catch (Exception ex)
                    {
                        SynchroDataHelper.WriteSynchroLog(ctx, SynchroDataType.DeliveryNoticeBill, ex.Message + System.Environment.NewLine + ex.StackTrace);
                    }
                }
            }

            HttpResponseResult result = new HttpResponseResult();

            result.Message = messages;

            dict.Add("result", (T)(Object)result);
            dict.Add("notices", (T)(Object)notices);

            return(dict);
        }
Exemple #19
0
 /// <summary>
 /// Indicates if value is Success or NotModified.
 /// </summary>
 public static bool IsSuccessOrNotModified(this HttpResponseResult val)
 {
     switch (val)
     {
     case HttpResponseResult.Success:
     case HttpResponseResult.NotModified:
         return(true);
     }
     return(false);
 }
Exemple #20
0
 private void ShowMessage(Context ctx, HttpResponseResult result)
 {
     if (result != null && !string.IsNullOrWhiteSpace(result.Message))
     {
         this.View.ShowErrMessage("", result.Message, MessageBoxType.Error);
     }
     else
     {
         this.View.ShowErrMessage("", "Fedex无响应信息返回!", MessageBoxType.Error);
     }
 }
Exemple #21
0
        public override void EndOperationTransaction(EndOperationTransactionArgs e)
        {
            base.EndOperationTransaction(e);

            List <DynamicObject> objects = e.DataEntitys.ToList();
            HttpResponseResult   result  = OperateAfterAudit(this.Context, objects);

            if (result != null && !result.Success && !string.IsNullOrWhiteSpace(result.Message))
            {
                throw new Exception(result.Message);
            }
        }
        public override HttpResponseResult ExecuteSynchro(IEnumerable <AbsSynchroDataInfo> sourceDatas, List <SynchroLog> logs, SynOperationType operationType)
        {
            HttpResponseResult    result = null;
            List <K3CustomerInfo> infos  = sourceDatas.Select(c => (K3CustomerInfo)c).ToList();


            string        sql     = string.Empty;
            List <string> addrNos = null;

            if (infos != null && infos.Count > 0)
            {
                addrNos = infos.Select(a => a.lstCustCtaInfo).SelectMany(a => a.Select(b => b.FNUMBER1)).ToList();

                foreach (var info in infos)
                {
                    if (info != null && info.lstCustCtaInfo != null && info.lstCustCtaInfo.Count > 0)
                    {
                        sql += string.Format(@"/*dialect*/delete from T_BD_CUSTLOCATION where FNUMBER in ('{0}')", string.Join("','", info.lstCustCtaInfo.Select(i => i.FNUMBER1)));

                        try
                        {
                            int count = DBUtils.Execute(this.K3CloudContext, sql);

                            if (count > 0)
                            {
                                result         = new HttpResponseResult();
                                result.Message = string.Format("客户编码【{0}】删除客户地址【{1}】成功!", info.FNumber, string.Join(",", info.lstCustCtaInfo.Select(i => i.FNUMBER1)));
                                result.Success = true;

                                LogUtils.WriteSynchroLog(this.K3CloudContext, this.DataType, result.Message);
                                RemoveRedisData(this.K3CloudContext, addrNos);
                            }
                            else
                            {
                                result         = new HttpResponseResult();
                                result.Message = "无客户地址需要删除";
                                result.Success = false;
                                LogUtils.WriteSynchroLog(this.K3CloudContext, this.DataType, result.Message);
                            }
                        }
                        catch (Exception ex)
                        {
                            result         = new HttpResponseResult();
                            result.Success = false;
                            result.Message = string.Format("客户编码【{0}】删除客户地址【{1}】失败:", info.FNumber, string.Join(",", info.lstCustCtaInfo.Select(i => i.FNUMBER1))) + System.Environment.NewLine + ex.Message;
                            LogUtils.WriteSynchroLog(this.K3CloudContext, this.DataType, "删除客户地址失败:" + System.Environment.NewLine + ex.Message + System.Environment.NewLine + ex.StackTrace);
                        }
                    }
                }
            }

            return(result);
        }
        public override void OnAddValidators(AddValidatorsEventArgs e)
        {
            base.OnAddValidators(e);

            List <DynamicObject> objects = e.DataEntities.ToList();

            result = OperateAfterAudit(this.Context, objects);

            AuditValidator validator = new AuditValidator(result, this.BusinessInfo.GetForm().Id);

            validator.EntityKey = "FBillHead";
            e.Validators.Add(validator);
        }
Exemple #24
0
        public virtual HttpResponseResult SynchroK3DataToWebSite(Context ctx, IEnumerable <AbsSynchroDataInfo> datas = null)
        {
            HttpResponseResult result = null;

            if (datas == null)
            {
                return(SynchroDataHelper.SynchroDataToHC(ctx, this.DataType, GetK3Datas(ctx, this.DyamicObjects, ref result), null, true, this.Direction));
            }
            else
            {
                return(SynchroDataHelper.SynchroDataToHC(ctx, this.DataType, datas, null, true, this.Direction));
            }
        }
Exemple #25
0
        public static void SendEmail(Context ctx, HttpResponseResult result, string guidString)
        {
            #region 查询邮件内容

            #endregion

            #region 根据上传数据确认邮件拆分

            string retouchKey = "^@!";//修饰键(排除编码有相同部分的数据,避免造成数据错误)

            #endregion

            Queue <MailMessage> mailList = new Queue <MailMessage>();

            #region 新上传邮件
            string reFilePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\HS_TemplateFile\\DeliTemplate.txt";    //邮件模板
            string reImgPath  = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\HS_TemplateFile\\healthCabin-log.png"; //公司log
            System.Net.Mail.Attachment att = new Attachment(reImgPath);
            string imgKey = "comLog";
            att.ContentId = imgKey;
            if (!File.Exists(reFilePath))
            {
                return;
            }
            var emailTemplate = File.ReadAllText(reFilePath, Encoding.Default);

            mailList = BuildBodyWithNo(ctx, result, emailTemplate, imgKey);//构建邮件主体内容
            #endregion

            #region 发送邮件

            if (mailList != null && mailList.Count > 0)
            {
                MailMsgService svc        = new MailMsgService();
                var            mailServer = svc.GetCurrUserMailInfo(ctx);
                svc.SrcBillType = "HS_SAL_ImportLogis";
                svc.SrcBillNo   = DateTime.Now.ToLongDateString();
                if (mailServer == null)
                {
                    foreach (var m in mailList)
                    {
                        m.Attachments.Dispose();
                    }
                    return;
                }
                svc.SendMailSynchro(ctx, mailList, mailServer);
                Thread.Sleep(mailList.Count() * 100);
            }

            #endregion
        }
Exemple #26
0
        public async Task SiteExtensionPreInstalledTests()
        {
            const string appName = "SiteExtensionBasicTests";

            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                var manager = appManager.SiteExtensionManager;

                // list
                List <SiteExtensionInfo> results = (await manager.GetRemoteExtensions()).ToList();
                Assert.True(results.Any(), "GetRemoteExtensions expects results > 0");

                // pick site extension
                var expectedId = _preInstalledExtensions.Keys.ToArray()[new Random().Next(_preInstalledExtensions.Count)];
                var expected   = results.Find(ext => String.Equals(ext.Id, expectedId, StringComparison.OrdinalIgnoreCase));
                TestTracer.Trace("Testing Against Site Extension {0}", expectedId);

                // get
                var result = await manager.GetRemoteExtension(expectedId);
                Assert.Equal(expected.Id, result.Id);
                Assert.Equal(expected.Version, result.Version);

                // clear local extensions
                results = (await manager.GetLocalExtensions()).ToList();
                foreach (var ext in results)
                {
                    Assert.True(await manager.UninstallExtension(ext.Id), "Delete must return true");
                }

                // install/update
                HttpResponseResult <SiteExtensionInfo> richResult = await manager.InstallExtension <SiteExtensionInfo>(expected.Id);
                Assert.Equal(expected.Id, richResult.Body.Id);
                Assert.Equal(expected.Version, richResult.Body.Version);

                // list
                results = (await manager.GetLocalExtensions()).ToList();
                Assert.True(results.Any(), "GetLocalExtensions expects results > 0");

                // get
                result = await manager.GetLocalExtension(expected.Id);
                Assert.Equal(expected.Id, result.Id);

                // delete
                var deleted = await manager.UninstallExtension(expected.Id);
                Assert.True(deleted, "Delete must return true");

                // list installed
                results = (await manager.GetLocalExtensions()).ToList();
                Assert.False(results.Exists(ext => ext.Id == expected.Id), "After deletion extension " + expected.Id + " should not exist.");
            });
        }
Exemple #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        public HttpResponseResult HttpGet(string url, IDictionary <string, string> headers)
        {
            HttpResponseResult result = null;
            Uri uri = null;

            if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri))
            {
                //LogManager.GetLogger().Trace("HttpGet:{0}", url);
                var httpRequest = CreateHttpRequest(uri, headers);
                result = SendRequest(httpRequest);
            }

            return(result);
        }
        /// <summary>
        /// 执行同步客户操作
        /// </summary>
        /// <param name="sourceDatas"></param>
        /// <param name="logs"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        public override HttpResponseResult ExecuteSynchro(IEnumerable <AbsSynchroDataInfo> sourceDatas, List <SynchroLog> logs, SynOperationType operationType)
        {
            HttpResponseResult    result = null;
            List <K3CustomerInfo> custs  = ConvertAbsSynchroObject(sourceDatas);
            JObject bizData = BuildSynchroDataJsons(sourceDatas, operationType);

            try
            {
                if (operationType == SynOperationType.UPDATE)
                {
                    //单据更新
                    result = ExecuteOperate(SynOperationType.SAVE, null, null, bizData.ToString());
                }
                return(result);
            }
            catch (Exception ex)
            {
                if (logs != null && logs.Count > 0)
                {
                    foreach (var log in logs)
                    {
                        log.IsSuccess = 0;
                        log.ErrInfor  = ex.Message + System.Environment.NewLine + ex.StackTrace;
                    }
                }
            }

            if (result == null)
            {
                return(null);
            }

            if (result.Success == false && result.FailedResult == null && result.Result == null)
            {
                //同步出现错误之类:如令牌错误,url错误之类的
                if (logs != null && logs.Count > 0)
                {
                    foreach (var log in logs)
                    {
                        log.IsSuccess = 0;
                        log.ErrInfor  = "数据同步失败:" + result.Message == null ? "" : result.Message;
                    }
                }

                return(result);
            }

            return(result);
        }
        public override void EndOperationTransaction(EndOperationTransactionArgs e)
        {
            base.EndOperationTransaction(e);

            if (this.BusinessInfo.GetForm().Id.CompareTo("SAL_SaleOrder") == 0)
            {
                List <DynamicObject> offline      = null;
                List <DynamicObject> online       = null;
                List <DynamicObject> dropshipping = null;
                this.DyamicObjects = e.DataEntitys.ToList();

                offline = this.DyamicObjects.Where(o =>
                {
                    DynamicObject oType = o["F_HS_SaleOrderSource"] as DynamicObject;
                    return(SQLUtils.GetFieldValue(oType, "FNumber").CompareTo("XXBJDD") == 0);
                }).ToList();

                online = this.DyamicObjects.Where(o =>
                {
                    DynamicObject oType = o["F_HS_SaleOrderSource"] as DynamicObject;
                    string orderSrc     = SQLUtils.GetFieldValue(oType, "FNumber");
                    return(orderSrc.CompareTo("HCWebPendingOder") == 0 || orderSrc.CompareTo("HCWebProcessingOder") == 0);
                }).ToList();

                dropshipping = this.DyamicObjects.Where(o =>
                {
                    DynamicObject oType = o["F_HS_SaleOrderSource"] as DynamicObject;
                    string orderSrc     = SQLUtils.GetFieldValue(oType, "FNumber");
                    return(orderSrc.CompareTo("DropShippingOrder") == 0);
                }).ToList();

                if (offline != null && offline.Count > 0)
                {
                    SalOrderType = "offline";
                    result       = OperateAfterAudit(this.Context, offline);
                }
                if (online != null && online.Count > 0)
                {
                    SalOrderType = "online";
                    result       = OperateAfterAudit(this.Context, online);
                }
                if (dropshipping != null && dropshipping.Count > 0)
                {
                    SalOrderType = "dropshipping";
                    result       = OperateAfterAudit(this.Context, dropshipping);
                }
            }
        }
 /// <summary>
 /// 更新同步后的操作(提交、审核)日志的提示信息
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="result"></param>
 /// <param name="dataType"></param>
 /// <param name="operateType"></param>
 public virtual void SynchroDataLog(Context ctx, HttpResponseResult result, SynchroDataType dataType, SynOperationType operateType)
 {
     if (result != null)
     {
         if (result.SuccessEntityNos != null && result.SuccessEntityNos.Count > 0)
         {
             string msg = string.Format("单据编码【{0}】{1}成功!", string.Join(",", result.SuccessEntityNos.Select(o => o.ToString())), operateType.ToString());
             result.Message = msg;
             LogUtils.WriteSynchroLog(ctx, dataType, msg);
         }
     }
     else
     {
         LogUtils.WriteSynchroLog(ctx, dataType, "" + dataType + "" + operateType + " 失败!");
     }
 }