Exemplo n.º 1
0
        private void PrivatePostSearch <T>(object items)
        {
            var temp = items as object[];

            string url      = temp[0].ToStr();
            object reqModel = temp[1];

            var json = PostJson(url, reqModel);

            this.Res = JsonUtil.DeSerializer <T>(json);
            var form = temp[2] as WaitingForm;

            _CloseWaiting(form);
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                if (this.Res == null)
                {
                    FormCommon.ShowErr("检索失败!");
                }

                var baseRes = this.Res as ResponseModelBase;
                if (!ResponseModelBase.SUCCESSED.Equals(baseRes.result))
                {
                    var msg = new StringBuilder();
                    msg.AppendLine("检索失败!");
                    if (!baseRes.errMessage.IsNullOrEmpty())
                    {
                        msg.AppendLine("原因:" + baseRes.errMessage);
                    }
                    FormCommon.ShowErr(msg.ToString());
                }
                _AfterResponse(this.Res);
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 打开服务器的PLM图纸
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="password"></param>
        /// <param name="userName"></param>
        public static void OpenFileForPlmPDF(string filePath, string SHARE_PATH, string SERVER_USERNAME, string SERVER_PASSWORD)
        {
            bool status = false;

            status = connectState(SHARE_PATH, SERVER_USERNAME, SERVER_PASSWORD);
            bool openFlag = false;

            if (status)
            {
                int num = 0;
                while (num < 10)
                {
                    try
                    {
                        System.Diagnostics.Process.Start(filePath);
                        openFlag = true;
                        break;
                    }
                    catch (Exception e)
                    {
                        Thread.Sleep(800);
                    }

                    num++;
                }
            }

            if (!openFlag)
            {
                FormCommon.ShowErr("设计图打开失败");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 检索类型的提交
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="url"></param>
        /// <param name="reqModel"></param>
        /// <param name="afterResponseCallBack">回调函数</param>
        /// <param name="message">替换消息,不为空的时候报该消息</param>
        /// <returns></returns>
        public void PostDelete(string url, object reqModel, AfterResponseDelegate afterResponseCallBack = null, string message = null)
        {
            _AfterResponse = afterResponseCallBack;
            this.Url       = url;
            this.ReqModel  = reqModel;
            string msg = message.IsNullOrEmpty() ? "是否删除?" : message;

            FormCommon.ShowDialog(msg, AfterDeleteCallBack);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 检索类型的提交
        /// </summary>
        /// <param name="url"></param>
        /// <param name="reqModel"></param>
        /// <param name="beforeSaveCallBack">保存确认之后,请求后台之前触发的回调</param>
        /// <param name="afterResponseCallBack">回调函数</param>
        /// <param name="message">替换消息,不为空的时候报该消息</param>
        /// <returns></returns>
        public void PostSaveEx(string url, object reqModel, BeforeSaveDelegate beforeSaveCallBack = null, AfterResponseDelegate afterResponseCallBack = null, string message = null)
        {
            _BeforeSave    = beforeSaveCallBack;
            _AfterResponse = afterResponseCallBack;
            this.Url       = url;
            this.ReqModel  = reqModel;
            string msg = message.IsNullOrEmpty() ? "是否保存?" : message;

            FormCommon.ShowDialog(msg, AfterSaveCallBack);
        }
Exemplo n.º 5
0
        private void PrivatePostDelete(object items)
        {
            var temp = items as object[];

            string url      = temp[0].ToStr();
            object reqModel = temp[1];

            var json = PostJson(url, reqModel);
            var res  = JsonUtil.DeSerializer <ResponseModelBase>(json);
            var form = temp[2] as WaitingForm;

            _CloseWaiting(form);
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                if (res == null)
                {
                    FormCommon.ShowErr("删除失败!");
                }
                else
                {
                    if (ResponseModelBase.SUCCESSED.Equals(res.result))
                    {
                        FormCommon.ShowMessage("删除成功!", (object item, bool isCloseOnly) =>
                        {
                            if (_AfterResponse != null)
                            {
                                _AfterResponse(res);
                            }
                        });
                    }
                    else
                    {
                        var msg = new StringBuilder();
                        msg.AppendLine("删除失败!");
                        if (!res.errMessage.IsNullOrEmpty())
                        {
                            msg.AppendLine("原因:" + res.errMessage);
                        }
                        FormCommon.ShowErr(msg.ToString());
                    }
                }

                if (_AfterResponse != null)
                {
                    _AfterResponse(res);
                }
            }));
        }
Exemplo n.º 6
0
        private string PostJson(string url, object reqModel)
        {
            try
            {
                var json = HttpUtil.Post(StaticClass._URL_HEAD + url, reqModel.Serializer());
                return(json);
            }
            catch
            {
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    FormCommon.ShowErr("服务器端错误!");
                }));
            }

            return("");
        }
Exemplo n.º 7
0
        private string GetJson(string url)
        {
            try
            {
                var json = HttpUtil.Get(StaticClass._URL_HEAD + url);
                return(json);
            }
            catch
            {
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    FormCommon.ShowErr("服务器端错误!");
                }));
            }

            return("");
        }