private void Reg_Click(object[] obj)
        {
            ///*****

            string      Phone = obj[0].ToString();
            PasswordBox pwd   = obj[1] as PasswordBox;
            Page        page  = obj[2] as Page;
            string      Pwd   = pwd.Password;
            ///****
            bool bo = Pwd.Length >= 6 ? true : false;

            if (bo)
            {
                RunState = true;
                string  RegCallBack   = account.Regist(Phone, "", Pwd);               //中间参数为注册时送的金额的验证码,可空
                JObject RegCallBackJo = (JObject)JsonConvert.DeserializeObject(RegCallBack);
                if (JObjectHelper.GetStrNum(RegCallBackJo["code"].ToString()) == 200) //注册成功
                {
                    RunState = false;
                    MessageBox.Show("注册成功");
                }
                else
                {
                    RunState = true;
                    MessageBox.Show(RegCallBackJo["message"].ToString());
                }
            }
            else
            {
                MessageBox.Show("密码长度不能小于6位");
            }
        }
示例#2
0
        public void forget_IsExistPhone(string Phone)  //手机号是否已注册
        {
            string  IsExistPhoneStr = account.IsExistPhone(Phone);
            JObject jo = (JObject)JsonConvert.DeserializeObject(IsExistPhoneStr);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) != 200)    //这里和注册时不一样
            {
                string  GetSmsCodeStr = account.GetSmsCode(Phone);
                JObject CodeJo        = (JObject)JsonConvert.DeserializeObject(GetSmsCodeStr);
                if (JObjectHelper.GetStrNum(CodeJo["code"].ToString()) == 200)
                {
                    thread = new Thread(GetCodeBtnText);
                    thread.Start();
                    code = CodeJo["message"].ToString();
                }
                else
                {
                    MessageBox.Show("验证码发送失败");
                }
            }
            else
            {
                MessageBox.Show("该号码还未注册");
            }
        }
        public JObject SaveToDB(IDBService dbProxy, string fileName, string baseFolder, string collection, string updateFilter = null, string fileBase64Data = null)
        {
            string destination = string.Format("{0}\\{1}{2}", ApplicationConfig.AppTempFolderPath, CommonUtility.RandomString(5), fileName);

            if (!string.IsNullOrEmpty(Save(fileName, destination, fileBase64Data)))
            {
                FileInfo fi             = new FileInfo(destination);
                var      contentType    = GetContentType(fi);
                var      fileUploadData = JObjectHelper.GetJObjectDbDataFromFile(fi, contentType, ApplicationConfig.AppTempFolderPath, "ZNxtAppUpload", baseFolder);
                File.Delete(destination);
                if (string.IsNullOrEmpty(updateFilter))
                {
                    _logger.Debug(string.Format("SaveToDB Writing new file  Name {0} ", fileName));

                    dbProxy.Write(collection, fileUploadData);
                    return(dbProxy.FirstOrDefault(collection, CommonConst.CommonField.DISPLAY_ID, fileUploadData[CommonConst.CommonField.DISPLAY_ID].ToString()));
                }
                else
                {
                    _logger.Debug(string.Format("SaveToDB updating file  Name {0} ", fileName));
                    fileUploadData.Remove(CommonConst.CommonField.DISPLAY_ID);
                    dbProxy.Write(collection, fileUploadData, updateFilter, true, MergeArrayHandling.Replace);
                    return(dbProxy.Get(collection, updateFilter, new List <string>()
                    {
                        CommonConst.CommonField.DISPLAY_ID, CommonConst.CommonField.FILE_PATH
                    }).First as JObject);
                }
            }

            return(null);
        }
示例#4
0
        private void Forget_Click(object[] obj)
        {
            string      Phone = obj[0].ToString();
            PasswordBox pwd   = obj[1] as PasswordBox;
            Page        page  = obj[2] as Page;
            string      Pwd   = pwd.Password;
            bool        bo    = Pwd.Length >= 6 ? true : true;

            if (bo)
            {
                RunState = true;
                string  ForgetCallBack   = account.ReviewPwd(Phone, Pwd);
                JObject ForgetCallBackJo = (JObject)JsonConvert.DeserializeObject(ForgetCallBack);
                if (JObjectHelper.GetStrNum(ForgetCallBackJo["code"].ToString()) == 200)
                {
                    //Button Btn = new Button
                    //{
                    //    Tag = "Login",
                    //};
                    //LoginHelper.LoginNavigate(Btn, page);
                    RunState = false;
                    MessageBox.Show("密码修改成功");
                }
                else
                {
                    RunState = false;
                    MessageBox.Show(ForgetCallBackJo["message"].ToString());
                }
            }
            else
            {
                MessageBox.Show("密码长度不能小于6位");
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="urlHelper"></param>
        /// <param name="routeName"></param>
        /// <param name="args"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSizeNo"></param>
        /// <param name="totalRecordCount"></param>
        /// <param name="draw"></param>
        /// <param name="summary"></param>
        public PageLinkBuilder(object urlHelper, string routeName, JObjectHelper args, long pageNo, long pageSizeNo,
                               long totalRecordCount, int draw = 1, string summary = "")
        {
            page         = pageNo;
            pageSize     = pageSizeNo;
            totalCount   = totalRecordCount;
            this.draw    = draw;
            this.summary = summary;
            totalPages   = totalRecordCount > 0 ? (int)Math.Ceiling(totalRecordCount / (double)pageSize) : 0;
            args.Add("pageSize", pageSize);
            args.Add("page", 1);
            var p1 = args.ToObject();

            args.Add("page", page - 1);
            var p2 = args.ToObject();

            args.Add("page", page + 1);
            var p3 = args.ToObject();

            args.Add("page", totalPages);
            var p4 = args.ToObject();
            //FirstPage = urlHelper.HttpRouteUrl(routeName, p1);
            //PreviousPage = page > 1 ? urlHelper.HttpRouteUrl(routeName, p2) : "";
            //NextPage = page < totalPages ? urlHelper.HttpRouteUrl(routeName, p3) : "";
            //LastPage = urlHelper.HttpRouteUrl(routeName, p4);
        }
 /// <summary>
 /// 获取同步文件列表
 /// </summary>
 void GetTrayFileList()
 {
     ThreadPool.QueueUserWorkItem((obj) =>
     {
         RunState    = true;
         EmptyIsShow = false;
         Bll.AUFileDocument document = new AUFileDocument();
         string temVal = document.GetTransferAUDiskFile(AccountInfo.Token, AccountInfo.ID);
         JObject jo    = (JObject)JsonConvert.DeserializeObject(temVal);
         if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 UnDownload.Clear();
                 int index = 0;
                 for (int i = 0; i < jo["dataList"].Count(); i++)
                 {
                     UnDownload.Add(new Model.TrayHistory()
                     {
                         Index        = index + 1,
                         FileUrl      = RequestAddress.server + jo["dataList"][i]["fileUrl"],
                         Id           = jo["dataList"][i]["ID"].ToString(),
                         FileName     = Path.GetFileName(jo["dataList"][i]["fileUrl"].ToString()),
                         CreateDate   = DateTime.Now,
                         CanDownload  = true,
                         DownTextShow = true
                     });
                     index++;
                     EmptyIsShow = false;
                 }
             });
         }
         RunState = false;
     });
 }
示例#7
0
 static void PlayGame(TcpClient client)
 {
     try
     {
         var gameSettings = client.ReadJson <GameSettings>();
         var worldState   = client.ReadJson <JObject>();
         client.WriteJson(new PlayerMessage
         {
             MessageType = MessageType.Info,
             Message     = JObjectHelper.CreateSimple("Hello, hero! welcome to the grand tournament")
         });
         var mainConnection = ConnectToServer();
         mainConnection.WriteJson(gameSettings);
         mainConnection.WriteJson(worldState);
         var server = ConnectToServer();
         Proxy.CreateChainAndStart(server, client);
         var resultTask = mainConnection.ReadJsonAsync <GameResult>();
         resultTask.ContinueWith(x =>
         {
             Console.WriteLine(x.IsFaulted
                 ? $"Cant get game results. Reason: {x.Exception}"
                 : "The game was finished with the following results:" + Environment.NewLine + x.Result.ToString());
         });
     }
     catch (Exception e)
     {
         Console.WriteLine("something went wrong...");
         Console.WriteLine(e.ToString());
     }
 }
示例#8
0
        private TSensorData ReadSensorData()
        {
            var message = client.ReadJson <PlayerMessage>();

            while (message.MessageType == MessageType.Info)
            {
                if (OnInfo != null)
                {
                    OnInfo(JObjectHelper.ParseSimple <string>(message.Message));
                }
                message = client.ReadJson <PlayerMessage>();
            }

            if (message.MessageType == MessageType.SensorData)
            {
                var sensorData = message.Message.ToObject <TSensorData>();
                if (OnSensorDataReceived != null)
                {
                    OnSensorDataReceived(sensorData);
                }
                return(sensorData);
            }

            throw new ClientException(JObjectHelper.ParseSimple <string>(message.Message));
        }
示例#9
0
        void FilePrintEvent(List <string> value)
        {
            NameValueCollection data = new NameValueCollection
            {
                { "sourceclient", "PC" }
            };

            Bll.AUFileDocument document = new AUFileDocument();
            string             temVal   = document.AUDiskFilePrint(AccountInfo.Token, value.ToArray(), data);
            JObject            jo       = (JObject)JsonConvert.DeserializeObject(temVal);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                //FileHelper.FileCount = jo["dataList"]["previewImgs"].Count();
                FileHelper.FileCount          = jo["dataList"]["filePageSection"].ToString().Split('-')[1].GetInt();
                FileHelper.FileUrl            = RequestAddress.server + jo["dataList"]["pdfUrl"];
                FileHelper.OrderId            = jo["dataList"]["id"].ToString();
                FileHelper.OrderNo            = jo["dataList"]["orderNo"].ToString();
                FileHelper.OrderState         = JObjectHelper.GetStrNum(jo["dataList"]["orderState"].ToString());
                FileHelper.LocalFileDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "filetemporary");
                FileHelper.LocalFilePath      = Path.Combine(FileHelper.LocalFileDirectory, jo["dataList"]["fileName"].ToString());
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    (new FilePreView()).Show();
                });
            }
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    MessageBox.Show(jo["message"].ToString());
                });
            }
            RunState = false;
        }
        public static Localization Parse(JObject jObject)
        {
            var localization = new Localization();

            localization.Id   = JObjectHelper.GetString(jObject, "id");
            localization.Name = JObjectHelper.GetString(jObject, "name");

            if (jObject["resourceGroups"] != null)
            {
                var jArrayResourceGroups = (JArray)jObject["resourceGroups"];
                foreach (JObject jObjectResourceGroup in jArrayResourceGroups)
                {
                    var resourceGroupName = JObjectHelper.GetString(jObjectResourceGroup, "name");

                    if (jObjectResourceGroup["resourceItems"] != null)
                    {
                        var jArrayResourceItems = (JArray)jObjectResourceGroup["resourceItems"];
                        foreach (JObject jObjectResourceItem in jArrayResourceGroups)
                        {
                        }
                    }
                }
            }

            return(localization);
        }
        /// <summary>
        /// 打开下载目录
        /// </summary>
        void OpenFloder(Object[] obj)
        {
            Button Btn      = obj[0] as Button;
            int    Index    = JObjectHelper.GetStrNum(Btn.Tag.ToString()) - 1;
            string FileName = UnDownload[Index].FileName;

            //打开文件资源管理器并选中文件
            System.Diagnostics.Process.Start("explorer.exe", "/select," + Path.Combine(localDownload, FileName));
        }
示例#12
0
        /// <summary>
        /// CheckBox选中
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="ch"></param>
        public void Check(ObservableCollection <TrayHistory> collection, object[] x)
        {
            CheckBox ch    = x[0] as CheckBox;
            int      Index = JObjectHelper.GetStrNum(ch.Tag.ToString());

            collection[Index - 1].IsChecked = (bool)ch.IsChecked;
            SelectChecked(collection);
            SelectCheckedAll(collection);
        }
示例#13
0
        void UploadFileEvent(List <string> value)
        {
            NameValueCollection data = new NameValueCollection
            {
                { "sourceClient", "PC" },
                { "audiskflag", "audiskpc" }
            };

            Bll.AUFileDocument document = new AUFileDocument();
            string             temVal   = document.AUDiskFilesCloud(AccountInfo.Token, value.ToArray(), data);
            JObject            jo       = (JObject)JsonConvert.DeserializeObject(temVal);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                for (int i = 0; i < value.Count; i++)
                {
                    XElement File = new XElement("File");
                    //File.SetElementValue("Id", UnDownload[Index].Id);
                    File.SetElementValue("FileName", Path.GetFileName(value[i].ToString()));
                    File.SetElementValue("FileUrl", value[i].ToString());
                    //File.SetElementValue("DownLoadPath", Path.Combine(localDownload, UnDownload[Index].FileName));
                    File.SetElementValue("CreateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                    FileOperationHelper.WriteXml(History, File);
                }

                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Delete(LocalTray);
                    var trayUpload = PageTrayHistoryUploadedViewModel.GetInstance();
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        SynchronizationContext.SetSynchronizationContext(
                            new System.Windows.Threading.DispatcherSynchronizationContext(System.Windows
                                                                                          .Application
                                                                                          .Current.Dispatcher));
                        SynchronizationContext.Current.Post(p =>
                        {
                            trayUpload.GetLocalTrayHistoryUploaded();
                        },
                                                            null);
                    });
                });
            }
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    MessageBox.Show(jo["message"].ToString());
                });
            }
            RunState = false;
        }
示例#14
0
 /// <summary>
 /// 单方面修改头像
 /// </summary>
 void ImageMouseBtnUp()
 {
     //WinImageClipping winImage=new WinImageClipping();
     //winImage.Show();
     Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
     ofd.Filter = "图像文件|*.jpg;*.png;*.jpeg;*.bmp;*.gif|所有文件|*.*";
     //ofd.InitialDirectory = @"C:\Users\Public\Pictures";
     ofd.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonPictures);
     ofd.Multiselect      = false;
     if (ofd.ShowDialog() == true)
     {
         //此处做你想做的事 ...=ofd.FileName;
         //MessageBox.Show(ofd.FileName);//显示文件完整路径
         ThreadPool.QueueUserWorkItem((obj) =>
         {
             System.Drawing.Image image = new Bitmap(ofd.FileName);
             int minValue  = image.Height > image.Width ? image.Width : image.Height;
             Bitmap bmp    = ThumbnailImage.CutImage(image, minValue, minValue);
             Bitmap bmp_60 = new Bitmap(bmp);
             bmp.Dispose();
             if (!Directory.Exists(Path.GetDirectoryName(SavePath.UserIconEdit)))
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(SavePath.UserIconEdit));
             }
             bmp_60.Save(SavePath.UserIconEdit, ImageFormat.Png);
             bmp_60.Dispose();
             Bll.Account account = new Account();
             string msg          = account.EditOwnInfo(AccountInfo.Token, new[] { SavePath.UserIconEdit }, null);
             JObject Jo          = (JObject)JsonConvert.DeserializeObject(msg);
             if (JObjectHelper.GetStrNum(Jo["code"].ToString()) == 200)
             {
                 AccountInfo.IconImage = Jo["dataList"]["icon"].ToString();
                 string NewFilePath    = Path.Combine(SavePath.UserInfo,
                                                      Path.GetFileNameWithoutExtension(AccountInfo.IconImage));
                 SavePath.UserIcon_30x30 = Path.Combine(NewFilePath, "_30x30.bmp");
                 if (!Directory.Exists(NewFilePath))
                 {
                     Directory.CreateDirectory(NewFilePath);
                 }
                 File.Copy(SavePath.UserIconEdit, Path.Combine(NewFilePath, Path.GetFileName(AccountInfo.IconImage)));
                 System.Drawing.Image _image = new Bitmap(Path.Combine(NewFilePath, Path.GetFileName(AccountInfo.IconImage)));
                 Bitmap icon_30x30           = ThumbnailImage.SizeImageWithOldPercent(_image, 30, 30);
                 Bitmap bmp30 = new Bitmap(icon_30x30);
                 icon_30x30.Dispose();
                 bmp30.Save(SavePath.UserIcon_30x30, ImageFormat.Bmp);
                 HeaderPath = Path.Combine(NewFilePath, Path.GetFileName(AccountInfo.IconImage));
                 ImagePath  = SavePath.UserIcon_30x30;
             }
         });
     }
 }
示例#15
0
        protected virtual void Deserialize(JObject jObject, LayoutElement element)
        {
            JObject jObjectLocation = (JObject)jObject["location"];
            int     x = JObjectHelper.GetInt32(jObject, "x", 0);
            int     y = JObjectHelper.GetInt32(jObject, "y", 0);

            element.Location = new Point(x, y);

            JObject jObjectSize = (JObject)jObject["size"];
            int     width       = JObjectHelper.GetInt32(jObject, "width", 0);
            int     height      = JObjectHelper.GetInt32(jObject, "height", 0);

            element.Size = new Size(width, height);
        }
示例#16
0
        public void SendError(Exception e)
        {
            var msh = new PlayerMessage
            {
                MessageType = MessageType.Error,
                Message     = JObjectHelper.CreateSimple <string>(e.GetType().Name + ": " + e.Message)
            };

            try
            {
                client.WriteJson(msh);
            }
            catch { }
        }
示例#17
0
        private bool CheckOverrideModule(string moduleName, bool IsOverride, ref JObject moduleObject)
        {
            var data = GetModule(moduleObject);

            if (!IsOverride && data != null)
            {
                _logger.Error(string.Format("Module already installed : {0}", moduleName), null);
                return(false);
            }
            if (data != null)
            {
                moduleObject = JObjectHelper.Marge(data, moduleObject, MergeArrayHandling.Union);
            }

            return(true);
        }
示例#18
0
        private void WriteCustomConfig(AppInstallerConfig requestData)
        {
            JObject customConfig = JObject.Parse(@"{
                    'groups': [
                        'user',
                        'sys_admin'
                    ]
                }");

            customConfig[CommonConst.CommonField.USER_TYPE]         = UserIDType.Email.ToString();
            customConfig[CommonConst.CommonField.IS_EMAIL_VALIDATE] = true;
            customConfig[CommonConst.CommonField.IS_ENABLED]        = true;

            customConfig[CommonConst.CommonField.DATA_KEY]            =
                customConfig[CommonConst.CommonField.NAME]            =
                    customConfig[CommonConst.CommonField.EMAIL]       =
                        customConfig[CommonConst.CommonField.USER_ID] = requestData.AdminAccount;
            customConfig[CommonConst.CommonField.PASSWORD]            = _encryptionService.GetHash(requestData.AdminPassword);

            JArray configData = new JArray();

            configData.Add(customConfig);

            var    path       = GetCustomConfigDirectoryPath();
            string configFile = string.Format("{0}\\{1}{2}", path, CommonConst.Collection.USERS, CommonConst.CONFIG_FILE_EXTENSION);

            JObjectHelper.WriteJSONData(configFile, configData);

            customConfig = new JObject();
            customConfig[CommonConst.CommonField.DATA_KEY] = CommonConst.CommonField.NAME;
            customConfig[CommonConst.CommonField.VALUE]    = requestData.Name;
            configData = new JArray();
            configData.Add(customConfig);
            configFile = string.Format("{0}\\{1}{2}", path, CommonConst.Collection.APP_INFO, CommonConst.CONFIG_FILE_EXTENSION);
            JObjectHelper.WriteJSONData(configFile, configData);

            configData = new JArray();
            foreach (var item in requestData.DefaultModules)
            {
                customConfig = new JObject();
                customConfig[CommonConst.CommonField.DATA_KEY] = item;
                customConfig[CommonConst.CommonField.VALUE]    = item;
                configData.Add(customConfig);
            }
            configFile = string.Format("{0}\\{1}{2}", path, CommonConst.Collection.DEFAULT_INSTALL_MODULES, CommonConst.CONFIG_FILE_EXTENSION);
            JObjectHelper.WriteJSONData(configFile, configData);
        }
示例#19
0
        JObject GotoPay(string begionPage, string endPage, string copies, bool isColor, bool isSingle)
        {
            Bll.OrderList orderList = new OrderList();
            Bll.Account   account   = new Account();
            string        priceVal  = account.GetPrintPrice(AccountInfo.Token);
            JObject       JoPrice   = (JObject)JsonConvert.DeserializeObject(priceVal);

            if (JoPrice["code"].GetInt() == 200)
            {
                //double BlackPrice = Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]);
                //double ColorPrice = Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]);
                int    PageCount = (JObjectHelper.GetStrNum(endPage) - JObjectHelper.GetStrNum(begionPage) + 1) * JObjectHelper.GetStrNum(copies);
                double payMoney  = PageCount * (isColor ? Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]):Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]));
                #region 双面订单金额减半
                if (!isSingle)
                {
                    ///重新计算页数
                    double ReSetTotalPage = Math.Ceiling(Convert.ToDouble((Convert.ToDouble(endPage) - Convert.ToDouble(begionPage) + 1) / 2));
                    payMoney = ReSetTotalPage * copies.GetInt() * (isColor ? Convert.ToDouble(JoPrice["dataList"]["enterpriseColorPrice"]) : Convert.ToDouble(JoPrice["dataList"]["enterpriseBlackPrice"]));
                }

                #endregion
                NameValueCollection data = new NameValueCollection
                {
                    { "orderid", OrderId },
                    { "amount", payMoney.ToString() },
                    { "paymode", "3" },
                    { "homepage", begionPage },
                    { "endpage", endPage },
                    { "iscolor", isColor?"1":"0" },
                    { "printmode", isSingle?"0":"1" },
                    { "copies", copies }
                };
                string temVal = orderList.OrderPay(AccountInfo.Token, data);
                //string temVal = orderList.OrderPayByBusiness(AccountInfo.Token, begionPage, endPage, copies, isColor, OrderNo);
                return((JObject)JsonConvert.DeserializeObject(temVal));
            }
            else
            {
                var RetVal = JsonConvert.SerializeObject(new
                {
                    code    = 404,
                    message = "订单生成失败"
                });
                return((JObject)JsonConvert.DeserializeObject(RetVal));
            }
        }
示例#20
0
        private void InstallCollections(ModuleInstallRequest request)
        {
            const string collection       = "collections";
            var          collectionFilter = @"{name: /^content\/" + collection + "/, " + CommonConst.CommonField.MODULE_NAME + ": '" + request.Name + "', " + CommonConst.CommonField.VERSION + ": '" + request.Version + "'}";

            foreach (var item in _dbService.Get(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, new RawQuery(collectionFilter)))
            {
                var fileSourceId   = item[CommonConst.CommonField.DISPLAY_ID].ToString();
                var fileName       = item[CommonConst.CommonField.NAME].ToString();
                var fileSize       = int.Parse(item[CommonConst.CommonField.FILE_SIZE].ToString());
                var contentType    = Mime.GetMimeType(fileName);
                var fileData       = JObjectHelper.GetJObjectDbDataFromFile(fileName, contentType, "content/wwwroot", request.Name, fileSize);
                var id             = fileData[CommonConst.CommonField.DISPLAY_ID].ToString();
                var collectionName = new FileInfo(fileName).Name.Replace(CommonConst.CONFIG_FILE_EXTENSION, "");
                var parent         = new FileInfo(fileName).Directory.Name;
                _logger.Debug($"InstallCollection File : {fileName}, Collection {collectionName}, Parent: { parent}");

                foreach (JObject joData in JObjectHelper.GetJArrayFromString(CommonUtility.GetStringFromBase64(_keyValueStorage.Get <string>(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, fileSourceId))))
                {
                    try
                    {
                        joData[CommonConst.CommonField.DISPLAY_ID]             = CommonUtility.GetNewID();
                        joData[CommonConst.CommonField.CREATED_DATA_DATE_TIME] = DateTime.Now;
                        joData[CommonConst.CommonField.MODULE_NAME]            = request.Name;
                        joData[CommonConst.CommonField.VERSION]     = request.Version;
                        joData[CommonConst.CommonField.ÌS_OVERRIDE] = false;
                        joData[CommonConst.CommonField.OVERRIDE_BY] = CommonConst.CommonValue.NONE;
                        var url = GetUIAppUrl(parent);
                        if (string.IsNullOrEmpty(url))
                        {
                            WriteToDB(joData, request.Name, collectionName, CommonConst.CommonField.DATA_KEY);
                        }
                        else
                        {
                            _logger.Debug($"Callling remote /ui/installcollection Flile : {fileName}, Collection {collectionName}, Parent: { parent}, url {url}");
                            joData[CommonConst.CommonValue.COLLECTION] = collectionName;
                            _apiGateway.CallAsync(CommonConst.ActionMethods.POST, "/ui/installcollection", "", joData, null, url).GetAwaiter().GetResult();
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error($"Error InstallCollections collection:{joData}", ex);
                    }
                }
            }
        }
        protected async override Task <string> ProviderJson()
        {
            if (Layouts == null)
            {
                Init(httpContext.RequestServices);
            }
            var dic = new Dictionary <string, string>();

            foreach (var item in Layouts)
            {
                dic.Add(item.ProviderFieldName, await item.ProviderField());
            }

            var json = JObjectHelper.CreateSimpleJson(dic).Replace(Environment.NewLine, string.Empty);

            return(json);
        }
示例#22
0
        private void InstallWWWRoot(ModuleInstallRequest request)
        {
            var wwwrootFilter = @"{name: /^content\/wwwroot/, " + CommonConst.CommonField.MODULE_NAME + ": '" + request.Name + "', " + CommonConst.CommonField.VERSION + ": '" + request.Version + "'}";

            _dbService.OverrideData(new JObject()
            {
                [CommonConst.CommonField.MODULE_NAME] = request.Name
            }, request.Name, CommonConst.CommonField.MODULE_NAME, CommonConst.Collection.STATIC_CONTECT);

            foreach (var item in _dbService.Get(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, new RawQuery(wwwrootFilter)))
            {
                var fileName = string.Empty;
                try
                {
                    var fileSourceId = item[CommonConst.CommonField.DISPLAY_ID].ToString();
                    fileName = item[CommonConst.CommonField.NAME].ToString();
                    var fileSize    = int.Parse(item[CommonConst.CommonField.FILE_SIZE].ToString());
                    var contentType = Mime.GetMimeType(fileName);
                    var fileData    = JObjectHelper.GetJObjectDbDataFromFile(fileName, contentType, "content/wwwroot", request.Name, fileSize);
                    fileData[CommonConst.CommonField.VERSION] = request.Version;
                    var id = fileData[CommonConst.CommonField.DISPLAY_ID].ToString();

                    var appUIFolder = GetAppFromUIFolder(fileData[CommonConst.CommonField.FILE_PATH].ToString());
                    if (!string.IsNullOrEmpty(appUIFolder))
                    {
                        fileData[CommonConst.CommonField.FILE_PATH] = fileData[CommonConst.CommonField.FILE_PATH].ToString().Replace($"/{appUIFolder}", "");
                    }
                    var appUIFolderUrl = GetUIAppUrl(appUIFolder);
                    if (string.IsNullOrEmpty(appUIFolderUrl))
                    {
                        WriteToDB(fileData, request.Name, CommonConst.Collection.STATIC_CONTECT, CommonConst.CommonField.FILE_PATH);
                        _keyValueStorage.Put <string>(CommonConst.Collection.STATIC_CONTECT, id, _keyValueStorage.Get <string>(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, fileSourceId), null, request.Name);
                    }
                    else
                    {
                        fileData[CommonConst.CommonField.DATA] = _keyValueStorage.Get <string>(CommonConst.Collection.MODULE_FILE_UPLOAD_CACHE, fileSourceId);
                        _apiGateway.CallAsync(CommonConst.ActionMethods.POST, "/ui/installpage", "", fileData, null, appUIFolderUrl).GetAwaiter().GetResult();
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error($"Error InstallWWWRoot file:{fileName}", ex);
                }
            }
        }
示例#23
0
        private void WriteEndTransaction(ILogger loggerController, string response)
        {
            JObject objTxnStartData = new JObject();
            JObject payload         = null;

            if (JObjectHelper.TryParseJson(response, ref payload))
            {
                payload.Remove(CommonConst.CommonField.HTTP_RESPONE_DEBUG_INFO);
                payload.Remove(CommonConst.CommonField.DATA);
                objTxnStartData[CommonConst.CommonField.PAYLOAD] = payload;
            }
            else
            {
                objTxnStartData[CommonConst.CommonField.PAYLOAD] = response;
            }
            // TODO
            // loggerController.Transaction(objTxnStartData, TransactionState.Finish);
        }
示例#24
0
        private void InstallDlls(string moduleDir, string moduleName)
        {
            var dllPath = string.Format("{0}\\lib\\net452\\", moduleDir);

            if (Directory.Exists(dllPath))
            {
                DirectoryInfo di    = new DirectoryInfo(dllPath);
                FileInfo[]    files = di.GetFiles("*.dll");
                CleanDBCollection(moduleName, CommonConst.Collection.DLLS);
                foreach (var item in files)
                {
                    FileInfo fi          = new FileInfo(item.FullName);
                    var      contentType = _httpProxy.GetContentType(fi.FullName);
                    var      joData      = JObjectHelper.GetJObjectDbDataFromFile(fi, contentType, string.Format("{0}", di.FullName), moduleName);
                    WriteToDB(joData, moduleName, CommonConst.Collection.DLLS, CommonConst.CommonField.FILE_PATH);
                }
            }
        }
示例#25
0
        public void Printer(Object[] x)
        {
            int     num1          = JObjectHelper.GetStrNum(x[0].ToString());
            int     num2          = JObjectHelper.GetStrNum(x[1].ToString());
            int     begion        = num1 <= num2 ? num1 : num2;
            int     end           = num1 > num2 ? num1 : num2;
            int     copies        = JObjectHelper.GetStrNum(x[2].ToString());
            bool    isColor       = BooleanHelper.GetBoolean(x[3]) ?? false;
            bool    isSinglePrint = BooleanHelper.GetBoolean(x[4]) ?? false;
            JObject jo            = null;

            switch (OrderState)
            {
            case 0:      //去支付
                jo = GotoPay(begion.ToString(), end.ToString(), copies.ToString(), isColor, isSinglePrint);
                break;

            case 10:     //未打印订单,重新生成一单
                jo = ReCreateOrder(begion.ToString(), end.ToString(), copies.ToString(), isColor?"1":"0", isSinglePrint?"0":"1");
                break;

            case 200:     //打印完成,重新生成
                jo = ReCreateOrder(begion.ToString(), end.ToString(), copies.ToString(), isColor ? "1" : "0", isSinglePrint?"0":"1");
                break;

            default:
                MessageBox.Show("信息错误");
                return;
            }

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Messenger.Default.Send <string>(OrderId, "ordercreatesuccess");
                });
                MessageBox.Show("订单生成成功");
            }
            else
            {
                MessageBox.Show(jo["message"].ToString());
            }
            //myDocument.ReCreateOrder(AccountInfo.Token, FileId, Path.GetFileName(LocalFilePath));
        }
示例#26
0
        void GetOrderList(int pageSize, int pageIndex, string orderState)
        {
            RunState    = true;
            EmptyIsShow = false;
            Bll.OrderList bllOrderList = new Bll.OrderList();
            string        Str          = bllOrderList.GetOrderList(AccountInfo.Token, pageSize.ToString(), pageIndex.ToString(),
                                                                   orderState);
            JObject jo = (JObject)JsonConvert.DeserializeObject(Str);

            if (JObjectHelper.GetStrNum(jo["code"].ToString()) == 200)
            {
                for (int i = 0; i < jo["dataList"].Count(); i++)
                {
                    var order = jo["dataList"][i];
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        OrderListAll.Add(new OrderListAll()
                        {
                            Index          = i + 1,
                            CreateTime     = DateTimeHelper.GetDateTime(order["CreateTime"].ToString()),
                            FileId         = order["FileId"].ToString(),
                            FileName       = order["FileName"].ToString(),
                            FileType       = order["FileType"].ToString(),
                            ID             = order["ID"].ToString(),
                            OrderCateoryId = order["OrderCategoryId"].ToString(),
                            OrderNo        = order["OrderNo"].ToString(),
                            OrderState     = JObjectHelper.GetStrNum(order["OrderState"].ToString()), //获取订单状态
                            PayMode        = order["PayMode"].ToString()
                        });
                    });
                }
            }
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    MessageBox.Show(jo["message"].ToString());
                });
            }

            RunState = false;
        }
        public override void Validate(object sender, ValidationEventArgs e)
        {
            string response = e.Response.BodyString;

            if (this.CheckEmptyResponse == true && string.IsNullOrWhiteSpace(response))
            {
                e.IsValid = true;
                return;
            }
            if (string.IsNullOrWhiteSpace(response))
            {
                e.IsValid = false;
                e.Message = "Response content was empty";
                return;
            }
            JObject json  = JObject.Parse(response);
            string  value = JObjectHelper.GetValueByPath(json, this.Path);

            e.IsValid = value == this.ExpectedValue;
        }
示例#28
0
        /// <summary>
        /// 单方面修改签名
        /// </summary>
        void EditSignature(object[] x)
        {
            TextBox _nicknameTextBox = x[0] as TextBox;
            string  str = _nicknameTextBox.Text;

            ThreadPool.QueueUserWorkItem((obj) =>
            {
                Bll.Account account      = new Account();
                NameValueCollection data = new NameValueCollection
                {
                    { "signature", str },
                };
                string msg = account.EditOwnInfo(AccountInfo.Token, null, data);
                JObject Jo = (JObject)JsonConvert.DeserializeObject(msg);
                if (JObjectHelper.GetStrNum(Jo["code"].ToString()) == 200)
                {
                    Signature = AccountInfo.Expertise = Jo["dataList"]["expertise"].ToString();
                }
            });
        }
示例#29
0
        private void InstallWWWRoot(string path, string moduleName)
        {
            var wwwrootPath = string.Format("{0}\\Content\\{1}", path, CommonConst.MODULE_INSTALL_WWWROOT_FOLDER);

            if (Directory.Exists(wwwrootPath))
            {
                DirectoryInfo di    = new DirectoryInfo(wwwrootPath);
                FileInfo[]    files = di.GetFiles("*.*", SearchOption.AllDirectories);

                CleanDBCollection(moduleName, CommonConst.Collection.STATIC_CONTECT);

                foreach (var item in files)
                {
                    FileInfo fi          = new FileInfo(item.FullName);
                    var      contentType = _httpProxy.GetContentType(fi);
                    var      joData      = JObjectHelper.GetJObjectDbDataFromFile(fi, contentType, di.FullName, moduleName);
                    WriteToDB(joData, moduleName, CommonConst.Collection.STATIC_CONTECT, CommonConst.CommonField.FILE_PATH);
                }
            }
        }
示例#30
0
        public object Exec(string action, IDBService dbProxy, ParamContainer helper)
        {
            JObject filter = JObject.Parse(CommonConst.Filters.IS_OVERRIDE_FILTER);

            filter[CommonConst.CommonField.METHOD] = CommonConst.ActionMethods.ACTION;
            filter[CommonConst.CommonField.ROUTE]  = action;

            var data = dbProxy.Get(CommonConst.Collection.SERVER_ROUTES, filter.ToString());

            if (data.Count == 0)
            {
                throw new KeyNotFoundException(string.Format("Not Found: {0}", filter.ToString()));
            }
            RoutingModel route = JObjectHelper.Deserialize <RoutingModel>(data[0].ToString());

            Func <dynamic> routeAction = () => { return(route); };

            helper[CommonConst.CommonValue.PARAM_ROUTE] = routeAction;

            return(Exec(route, helper));
        }