Пример #1
0
        public ValidationResults Validate(CRMSolution solution)
        {
            ValidationResults allValidatorsResult = new ValidationResults();

            if (Validators == null || Validators.Count == 0)
            {
                throw new InvalidOperationException("No Validators exist, please change the validation settings first");
            }

            //publish all customizations first if the settings allow it
            if (MySettings.AlwaysPublish)
            {
                OnProgressChanged?.Invoke(this, new ProgressEventArgs("Publishing customizations"));
                PublishAllXmlRequest publishRequest = new PublishAllXmlRequest();
                CRMService.Execute(publishRequest);
            }

            // start the validators
            foreach (IValidator validator in Validators)
            {
                validator.OnValidatorError += (s, e) =>
                {
                    OnError?.Invoke(s, e);
                };
                validator.OnValidatorProgress += (s, e) =>
                {
                    OnProgressChanged?.Invoke(s, new ProgressEventArgs(e.Message));
                };

                ValidationResults validatorResult = validator.Validate();
                allValidatorsResult.AddResultSet(validatorResult);
            }

            return(allValidatorsResult);
        }
 public ClientPageViewModel()
 {
     _service = new CRMService();
     Load();
     SubmitDelete    = new DelegateCommand(DeleteClient);
     SubmitNewClient = new DelegateCommand(SaveNewClient);
 }
 public LinePageViewModel()
 {
     _service     = new CRMService();
     SubmitDelete = new DelegateCommand(DeleteLine);
     SubmitSave   = new DelegateCommand(SaveNewClientLine);
     Load();
 }
Пример #4
0
        public ValidationResults Validate()
        {
            try
            {
                ValidationResults results = new ValidationResults();

                //get all solution compontents of type workflow that belong to the specified solution
                QueryExpression processQuery = new QueryExpression("solutioncomponent");
                processQuery.ColumnSet = new ColumnSet(true);
                processQuery.Criteria.AddCondition("componenttype", ConditionOperator.Equal, (int)SolutionComponentType.Process);
                processQuery.Criteria.AddCondition("solutionid", ConditionOperator.Equal, Solution.Id);

                var allProcesses = CRMService.RetrieveMultiple(processQuery);
                if (allProcesses != null && allProcesses.Entities.Count > 0)
                {
                    results = ValidateProcesses(allProcesses.Entities);
                }
                return(results);
            }
            catch (Exception ex)
            {
                OnValidatorError?.Invoke(this, new ErrorEventArgs(ex));
                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// For now, this function checks for inactive processes that needs to be removed form the solution
        /// </summary>
        /// <param name="processEntities"></param>
        /// <returns></returns>
        private ValidationResults ValidateProcesses(DataCollection <Entity> processEntities)
        {
            ValidationResults results = new ValidationResults();

            QueryExpression processesQuery = new QueryExpression("workflow");

            processesQuery.ColumnSet = new ColumnSet(true);
            var allIds = processEntities.Select(x => x.GetAttributeValue <Guid>("objectid")).ToArray <Guid>();

            processesQuery.Criteria.AddCondition(new ConditionExpression("workflowid", ConditionOperator.In, allIds));
            var fullProcesses = CRMService.RetrieveMultiple(processesQuery);


            //check if any is in draft mode
            foreach (var fullProcess in fullProcesses.Entities)
            {
                // check if the process is activated or not
                if (fullProcess.GetAttributeValue <OptionSetValue>("statuscode").Value == 1)
                {
                    var singleResult = new ValidationResult();
                    singleResult.Description = $"{fullProcess.GetAttributeValue<string>("name")} is not activated";
                    singleResult.Suggestions = $"Inactive processes should be removed from unmanaged solutions";
                    singleResult.Regarding   = fullProcess.FormattedValues["category"];
                    results.AddResult(singleResult);
                }
            }

            return(results);
        }
Пример #6
0
        private void InitCommand()
        {
            CustCommand = new DelegateCommand((obj) =>
            {
                //var ss1 = CRMService.GetQueryXoqlData<OpportunityAccountQueryXoqlModel>(@"select  accountId.accountName AccountName,opportunityName OpportunityName from opportunity");
                //if (ss1.code == 200)
                //{
                //	OpportunityAccountQueryXoqlModel[] rr = ss1.data.records;
                //	SqlHelper.LoadArrayToDBModelTable(rr, "OpportunityAccountQueryXoqlTable");
                //}
                //else
                //{
                //	MessageBox.Show($"{ss1.msg}");
                //}


                var ss2 = CRMService.GetQueryXoqlData <SROpportunityQueryXoqlModel>(@" select customItem177__c  ItemCode,opportunityName  ItemName,ownerId XiangMuJingLi,dbcVarchar6 ShiChangZhiChi,customItem172__c YeWuZhiChi,
customItem175__c JiShuZhiChi,customItem182__c PinZhiZhiChi,customItem173__c ChanPinJingLi,customItem180__c JiFuZhiChi,customItem181__c SeCaiZhiChi  from opportunity ");
                if (ss2.code == 200)
                {
                    SROpportunityQueryXoqlModel[] rr = ss2.data.records;
                    SqlHelper.LoadArrayToDBModelTable(rr, "SROpportunityXoqlTable");
                }
                else
                {
                    MessageBox.Show($"{ss2.code} \r\n{ss2.msg}");
                }

                //var ss = CRMService.GetQueryXoqlData(Token, "opportunity", " select dbcSelect1,opportunityName,customItem169__c,(select accountName from account where id=opportunity.customItem169__c) accountName from  opportunity ");
                // var xx = CRMService.GetEntityDescription();
                //Text1 = CRMService.GetEntityDescriptionString();
            });
        }
Пример #7
0
        public IItem GetItem(ISiteSetting siteSetting, string itemUrl, out Sobiens.Connectors.Entities.Folder itemFolder)
        {
            ICRMService spService = new CRMService();

            itemFolder = null;
            return(null);
        }
 public ClientTypePageViewModel()
 {
     _service     = new CRMService();
     SubmitSave   = new DelegateCommand(SaveNewClientType);
     SubmitUpdate = new DelegateCommand(UpdateClientType);
     SubmitDelete = new DelegateCommand(DeleteClientType);
     LoadClientTypess();
 }
Пример #9
0
 public UserPage()
 {
     _service = new CRMService();
     GetClients();
     this.DataContext = this;
     UserInstance     = this;
     InitializeComponent();
 }
Пример #10
0
 public ClientPropertyPageViewModel()
 {
     _service = new CRMService();
     Load();
     _Clients        = LoginClientViewModel.client;
     _ClientTypes    = LoginClientViewModel.client.ClientType;
     _Lines          = LoginClientViewModel.client.Lines;
     _CurrentPackage = _Package.Where(P => P.Id == _Lines.Select(l => l.PackageId).FirstOrDefault()).FirstOrDefault();
 }
Пример #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSingleton <IConfiguration>(Configuration);
            var crmService = new CRMService();

            services.AddSingleton <ICRMService>(_ => crmService);
            services.AddScoped <CrmServiceContext>(_ => new CrmServiceContext(crmService._instance));
            services.AddApplicationInsightsTelemetry(Configuration["APPINSIGHTS_CONNECTIONSTRING"]);
        }
Пример #12
0
        public ADSBotServices(IConfiguration configuration, ConversationState conversationState,
                              UserState userState, CRMService crmService, DataService dataService)
        {
            ConversationState = conversationState;
            Configuration     = configuration;
            DataService       = dataService;
            UserState         = userState;
            CRM = crmService;

            UserProfileAccessor = UserState.CreateProperty <UserProfile>(nameof(UserProfile));
            DialogStateAccessor = ConversationState.CreateProperty <DialogState>(nameof(DialogState));
            //Used by micrsoft dialog classes
            GenericUserProfileAccessor = UserState.CreateProperty <Dictionary <string, object> >(nameof(UserProfile));

            QnAOptions = new QnAMakerOptions();

            LeadQualQnA = new QnAMaker(
                new QnAMakerEndpoint
            {
                KnowledgeBaseId = configuration["qna:QnAKnowledgebaseId"],
                EndpointKey     = configuration["qna:QnAEndpointKey"],
                Host            = configuration["qna:QnAEndpointHostName"]
            }, QnAOptions);

            //Apparently the constructor overrides the properties with defaults?
            QnAOptions.ScoreThreshold = 0;

            var luisApplication = new LuisApplication(
                configuration["luis:id"],
                configuration["luis:endpointKey"],
                configuration["luis:endpoint"]);

            var recognizerOptions = new LuisRecognizerOptionsV3(luisApplication)
            {
                IncludeAPIResults = true,
                PredictionOptions = new Microsoft.Bot.Builder.AI.LuisV3.LuisPredictionOptions()
                {
                    IncludeAllIntents   = true,
                    IncludeInstanceData = true
                }
            };

            LuisRecognizer = new LuisRecognizer(recognizerOptions);
        }
Пример #13
0
        /// <summary>
        /// 在一个action被执行前调用
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            int productid = 1;
            BaseController control = filterContext.Controller as BaseController;

            //跳过对/Base/的任何检查
            if (control != null && control.GetType() == typeof(BaseController))
            {
                base.OnActionExecuting(filterContext);
                return;
            }

            string LoginIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] as string;
            //用户权限较验
            CRMService crm = new CRMService();

            //获得当前用户的登陆信息
            CookieUserInfo cui = MembershipService.GetUserCookie();
            //CookieUserInfo cui = new CookieUserInfo() { UserID = "1", UserName = "******", LoginGuid = Guid.NewGuid().ToString() };
            Int32? userid = null;
            if (cui != null)
            {
                userid = Convert.ToInt32(cui.UserID);
                Hashtable counthtparm = new Hashtable();
                counthtparm["UserID"] = userid.Value;
                counthtparm["LoginIP"] = LoginIP;
                int countIP = CRMMapper.Get().QueryForObject<int>("BlackIP.MyFind", counthtparm);
                if (countIP != 0)
                {
                    filterContext.Result = new RedirectResult("/Base/IPError.mvc");
                }
            }
            else
            {
                userid = -1;
                Hashtable counthtparm = new Hashtable();
                counthtparm["UserID"] = userid.Value;
                counthtparm["LoginIP"] = LoginIP;
                int countIP = CRMMapper.Get().QueryForObject<int>("BlackIP.MyFind", counthtparm);
                if (countIP != 0)
                {
                    filterContext.Result = new RedirectResult("/Base/IPError.mvc");
                }
            }

            //用户ip使用次数校验
            int count = 0;
            int times = 30;
            Hashtable htparm = new Hashtable();
            if (userid != null)
                htparm["UserID"] = userid.Value;
            else
                htparm["UserID"] = -1;
            htparm["LoginIP"] = LoginIP;
            htparm["Now"] = DateTime.Now;
            htparm["Last"] = DateTime.Now.AddMinutes(-1);
            count = CRMMapper.Get().QueryForObject<Int32>("UserLogin.Total", htparm);
            if (count < times)
            {
                UserLogin userlogin = new UserLogin();
                if (userid != null)
                    userlogin.UserID = userid.Value;
                else
                    userlogin.UserID = -1;
                userlogin.LoginIP = LoginIP;
                userlogin.LoginTime = DateTime.Now;
                userlogin.FuntionCode = control.functionCode();
                userlogin.URL = HttpContext.Current.Request.Url.PathAndQuery;
                new UserLoginDao().Insert(userlogin);

            }
            else
            {
                BlackIP bIP = new BlackIP();
                bIP.LogIP = LoginIP;
                bIP.UserID = userid.Value;
                bIP.BlackTime = DateTime.Now;
                new BlackIPDao().Insert(bIP);
                filterContext.Result = new RedirectResult("/Base/IPError.mvc");
            }
            //检验是否是重复登录
            if (userid != null)
            {
                string url = HttpContext.Current.Request.Url.PathAndQuery;
                UserLoginGuidService ulgs = new UserLoginGuidService();
                UserLoginGuid ulg = ulgs.selectbyuserid(userid.Value);
                if (ulg != null)
                {
                    if (ulg.LoginGuid != cui.LoginGuid)
                    {
                        UserModel olduser = new MembershipUserService().GetUserName(Int32.Parse(cui.UserID));
                        DateTime oldtime = olduser.LastLoginDate;
                        string oldip = olduser.LastLoginIp;
                        if (oldtime.AddMinutes(30) < DateTime.Now || oldip == LoginIP)
                            filterContext.Result = new RedirectResult("/Base/MutiLogin.mvc?Url=" + url);
                        else
                        {
                            int t = 30 - (DateTime.Now - oldtime).Minutes;
                            filterContext.Result = new RedirectResult("/Base/LessTime.mvc?t=" + t);
                        }
                    }
                }
            }
            int helptopic = 0;
            EnumPrivilegeCheckResult checkresult = crm.UserPrivilegeCheck(control.ProductID, control.functionCode(), userid, out helptopic);

            //处理验证结果
            switch (checkresult)
            {
                case EnumPrivilegeCheckResult.未登陆失败:
                    filterContext.Result = new RedirectResult("/Base/NotLogin.mvc");
                    return;

                case EnumPrivilegeCheckResult.非会员失败:
                    filterContext.Result = new RedirectResult("/Base/NotMember.mvc/" + helptopic);
                    return;

                case EnumPrivilegeCheckResult.会员等级不足失败:
                    filterContext.Result = new RedirectResult("/Base/MemberLevelError.mvc/" + helptopic);
                    return;

                case EnumPrivilegeCheckResult.未购买产品失败:
                    filterContext.Result = new RedirectResult("/Base/NotBuyer.mvc/" + helptopic);
                    return;
                case EnumPrivilegeCheckResult.试用账号超过次数上限:
                    filterContext.Result = new RedirectResult("/Base/TryError.mvc");
                    return;

            }
            //如果是子账户,检查是否有相应权限
            if (userid != null && new MemberUserInfoDao().Find((int)userid) != null)
            {
                int uid = (int)userid;
                bool IsAdmin = new MemberUserInfoDao().IsAdmin(uid);
                if (!IsAdmin)//如果是子账户
                {
                    //找到子账户的functionlist
                    string functionlist = FindFunctionlist(uid, productid);
                    List<string> codelist = new List<string>();
                    if (functionlist != null)
                    {
                        string[] list = functionlist.Split(',');
                        //再找到相应的functioncode

                        foreach (string str in list)
                        {
                            if (str.Trim().ToLower() != "on")
                            {
                                codelist.Add(new ProductFunctionDao().Find(Int32.Parse(str)).FunctionCode);
                            }
                        }
                    }
                    codelist.Add("IndexPage");//首页都有
                    //如果当前code不在列表中则失败
                    if (!codelist.Contains(control.functionCode()))
                    {
                        filterContext.Result = new RedirectResult("/Base/NotAdmin.mvc");
                    }
                }
            }
            //通过检杳,允许访问
            base.OnActionExecuting(filterContext);
        }
Пример #14
0
        //得到本品(多选)
        public JsonResult GetOwnPMuti(string uid, string commonname, string formulation, string chinesespecification, string company, string page)
        {
            int pagesize = 20;
            int ipage = Int32.Parse(page);
            string ec = new CRMService().GetEnterpriseMemberInfo(Convert.ToInt32(uid)).EnterpriseCode;
            Hashtable htparm = new Hashtable();
            htparm["start"] = pagesize * (ipage - 1) + 1;   //记录开始数
            htparm["end"] = ipage * pagesize;    //记录结束数
            htparm["enterprisecode"] = ec;
            if (commonname != "")
                htparm["CommonName"] = commonname;
            if (formulation != "")
                htparm["Formulation"] = formulation;
            if (chinesespecification != "")
                htparm["ChineseSpecification"] = chinesespecification;
            if (company != "")
                htparm["ChineseManufactureName"] = company;
            string html = "<tr><th></th><th>通用名</th><th>剂型</th><th>规格</th><th>生产企业</th></tr>";

            IList<IDictionary> ownlists = CRMMapper.Get().QueryForList<IDictionary>("MemberProduct.GetOwnProduct", htparm);
            if (ownlists.Count > 0)
            {
                foreach (IDictionary o in ownlists)
                {
                    html += "<tr><td><input type='checkbox' name='groupradio' class='ownproduct' value='" + o["ProductCode"] + "' /></td>";
                    html += "<td>" + o["ChineseProductName"] + "</td><td>" + o["Formulation"] + "</td><td>" + o["ChineseSpecification"] + "</td><td>" + o["ChineseManufactureName"] + "</td></tr>";
                }
            }
            int totalcount = CRMMapper.Get().QueryForObject<int>("MemberProduct.GetOwnProductCount", htparm);
            if (totalcount > 200)
                totalcount = 200;
            string pagehtml = "总共" + totalcount + "条 ";
            int pagenums = 0;
            if (totalcount % pagesize != 0)
                pagenums = totalcount / pagesize + 1;
            else
                pagenums = totalcount / pagesize;
            for (int i = 1; i <= pagenums; i++)
            {
                pagehtml += "<a href='javascript:void(0)' class='ownpage'>" + i + "</a>";
            }
            return Json(new { content = html, page = pagehtml });
        }
 public LoginClientViewModel()
 {
     SubmitLogin = new DelegateCommand(_loginClient);
     _service    = new CRMService();
 }
        private void InitCommand()
        {
            CRMUserSyncCommand = new DelegateCommand((obj) =>
            {
                var r = CRMService.GetQueryXoqlData <SRUserQueryXoqlModel>(@"select  id Id,name Name,dimDepart DeptId  from user ;");
                if (r.code == 200)
                {
                    SqlHelper.ExecuteNonQuerySR(" truncate table SRUserXoqlTable ;", null);
                    SqlHelper.LoadIEnumerableToDBModelTableSR(r.data.records, "SRUserXoqlTable");
                }
            });

            CRMItemSyncCommand = new DelegateCommand((obj) =>
            {
                List <SROpportunityQueryXoqlDbModel> lists = new List <SROpportunityQueryXoqlDbModel>();
                var ss2 = CRMService.GetQueryXoqlData <SROpportunityQueryXoqlModel>(@" select customItem177__c  ItemCode,opportunityName  ItemName
                            ,ownerId XiangMuJingLi,dbcVarchar6 ShiChangZhiChi,customItem172__c YeWuZhiChi,
                            customItem175__c JiShuZhiChi,customItem182__c PinZhiZhiChi,customItem173__c ChanPinJingLi,customItem180__c JiFuZhiChi,customItem181__c SeCaiZhiChi,createdAt BeginDate
                        from opportunity  where  dimDepart=1047572968276306 ");
                if (ss2.code == 200)
                {
                    SROpportunityQueryXoqlModel[] rr = ss2.data.records;
                    foreach (var item in rr)
                    {
                        SROpportunityQueryXoqlDbModel model = new SROpportunityQueryXoqlDbModel
                        {
                            Id             = item.Id,
                            BeginDate      = TypeConvertHelper.ConvertTimeStampToDateTime(item.BeginDate),
                            EndDate        = TypeConvertHelper.ConvertTimeStampToDateTime(item.EndDate),
                            ItemCode       = item.ItemCode,
                            ItemName       = item.ItemName,
                            HouDuanZhiChi  = item.HouDuanZhiChi,
                            JiFuZhiChi     = item.JiFuZhiChi,
                            PinZhiZhiChi   = item.PinZhiZhiChi,
                            SeCaiZhiChi    = item.SeCaiZhiChi,
                            ShiChangZhiChi = item.ShiChangZhiChi,
                            XiangMuJingLi  = item.XiangMuJingLi,
                            YeWuZhiChi     = item.YeWuZhiChi == null? "": string.Join(",", item.YeWuZhiChi),
                            ChanPinJingLi  = item.ChanPinJingLi == null? "" :string.Join(",", item.ChanPinJingLi),
                            JiShuZhiChi    = item.JiShuZhiChi == null ?"":string.Join(",", item.JiShuZhiChi),
                        };

                        lists.Add(model);
                    }
                    SqlHelper.ExecuteNonQuerySR(" truncate table SROpportunityXoqlTable ;", null);
                    SqlHelper.LoadIEnumerableToDBModelTableSR(lists, "SROpportunityXoqlTable");
                }
                else
                {
                    MessageBox.Show($"{ss2.code} \r\n{ss2.msg}");
                }
            });

            EmployeeCostImportCommand = new DelegateCommand((obj) =>
            {
                //文件选择窗口
                System.Windows.Forms.OpenFileDialog opd = new System.Windows.Forms.OpenFileDialog
                {
                    Title  = "选择文件",
                    Filter = "EXCEL文件|*.xls*"  //第一个参数是名称,随意取,第二个是模式匹配, 多个也是用“|”分割
                };

                if (opd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    int monthId = Convert.ToInt32(CommonService.ImportExcelToDatabaseTableWithoutSeq(opd.FileName, "SREmployeeCost", "SR"));
                    SettleMonthSearchedItem.Id         = monthId;
                    SettleMonthSearchedItem.SearchText = monthId.ToString();
                    // 数据验证后加载验证模型列表到表格
                    //MessageBox.Show("导入成功");
                }
                opd.Dispose();
            });

            ItemProfitSettleCommand = new DelegateCommand((obj) =>
            {
                if (SettleMonthSearchedItem == null)
                {
                    MessageBox.Show("请先导入人员支出Excel");
                    return;
                }

                //同步OA费用数据到松润数据库
                DataTable dataTable = _itemProfitAccountingService.GetOaItemCostDataTable(SettleMonthSearchedItem.Id);
                _itemProfitAccountingService.ImportDataTableToDatabaseTableSR(dataTable, "SROaItemCost");

                // 计算最终的结果
                _itemProfitAccountingService.AccountItemProfit(SettleMonthSearchedItem.Id);
                ItemProfitAccountingQueryCommand.Execute(null);
            });

            ItemProfitAccountingQueryCommand = new DelegateCommand((obj) =>
            {
                ItemProfitAccountingLists.Clear();
                _itemProfitAccountingService.GetItemProfitAccountingLists($" and ItemName like '%{ItemNameParameter}%' ").ForEach(x => ItemProfitAccountingLists.Add(x));
                ListsSum   = ItemProfitAccountingLists.Sum(x => x.Profit);
                ListsCount = ItemProfitAccountingLists.Count();
            });

            ItemProfitDeleteCommand = new DelegateCommand((obj) =>
            {
                MessageBoxResult result = MessageBox.Show($"确认删除【{SettleMonthSearchedItem.Id}】已经结算的数据", "温馨提示", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                }
            });

            ItemProfitMonthlyQueryCommand = new DelegateCommand((obj) =>
            {
                if (SettleMonthSearchedItem == null)
                {
                    return;
                }
                ItemProfitAccountingMonthlyLists.Clear();
                _itemProfitAccountingService.GetItemProfitAccountingMonthlyLists($" and SettleMonth = {SettleMonthSearchedItem.Id} ").ForEach(x => ItemProfitAccountingMonthlyLists.Add(x));
            });

            SelectionChangedCommand = new DelegateCommand((obj) =>
            {
                if (ItemProfitAccountingSelectedItem == null)
                {
                    return;
                }
                ItemProfitAccountingMonthlyLists.Clear();
                _itemProfitAccountingService.GetItemProfitAccountingMonthlyLists($" and ItemCode = {ItemProfitAccountingSelectedItem.ItemCode} ").ForEach(x => ItemProfitAccountingMonthlyLists.Add(x));
            });
        }
Пример #17
0
        /// <summary>
        /// 得到sitemaster上的信息显示
        /// </summary>
        /// <returns></returns>
        protected Dictionary<string, string> GetSiteMaster()
        {
            Dictionary<string, string> sitemaster = new Dictionary<string, string>();
            if (this.CurrentUserInfo == null)
            {
                sitemaster["userid"] = "-1";
                sitemaster["EnterpriseName"] = "游客";
                sitemaster["Memberlevel"] = "匿名用户";
                sitemaster["intlevel"] = "0";
                sitemaster["isadmin"] = "0";
                sitemaster["EndTime"] = "999";

            }
            else
            {
                string username = MembershipService.GetUserName(Convert.ToInt32(this.CurrentUserInfo.UserID));
                int IsAdmin = 0;
                if (EnterPriseMemberInfo == null)
                {
                    sitemaster["userid"] = this.CurrentUserInfo.UserID;
                    sitemaster["EnterpriseName"] = username;
                    sitemaster["Memberlevel"] = "免费注册用户";
                    sitemaster["intlevel"] = "1";
                    sitemaster["isadmin"] = IsAdmin.ToString();
                    sitemaster["EndTime"] = "999";
                }
                else
                {
                    IsAdmin = new CRMService().GetMemberUser(Convert.ToInt32(this.CurrentUserInfo.UserID)).IsMemberAdmin;
                    sitemaster["userid"] = this.CurrentUserInfo.UserID;
                    sitemaster["EnterpriseName"] = EnterPriseMemberInfo.EnterpriseName + " " + username;
                    sitemaster["isadmin"] = IsAdmin.ToString();
                    IList<OrderInfo> orderlist = new OrderInfoDao().QueryUserProductOrder(EnterPriseMemberInfo.MemberID, 1);
                    if (orderlist.Count > 0)//服务期内
                    {
                        DateTime servicestarttime = orderlist[0].ServiceStartTime;
                        DateTime serviceendtime = orderlist[0].ServiceEndTime;
                        if (serviceendtime > servicestarttime.AddMonths(2))
                            sitemaster["istest"] = "0";
                        else
                            sitemaster["istest"] = "1";
                        if (orderlist[0].VersionID == 1)
                        {
                            sitemaster["Memberlevel"] = new CRMService().GetUserMemberLevel(Int32.Parse(CurrentUserInfo.UserID)).ToString();
                        }
                        else
                        {
                            sitemaster["Memberlevel"] = "定制";
                        }
                        sitemaster["intlevel"] = ((int)new CRMService().GetUserMemberLevel(Int32.Parse(CurrentUserInfo.UserID))).ToString();
                        DateTime endtime = CRMMapper.Get().QueryForObject<DateTime>("OrderInfo.GetEndTime", EnterPriseMemberInfo.MemberID);
                        TimeSpan ts = endtime.Subtract(DateTime.Now);
                        if (ts.Days < 30)
                            sitemaster["EndTime"] = ts.Days.ToString();
                        else
                            sitemaster["EndTime"] = "999";
                    }
                    else//服务到期
                    {
                        sitemaster["Memberlevel"] = "免费注册用户";
                        sitemaster["intlevel"] = "1";
                        sitemaster["EndTime"] = "999";
                    }

                }
            }

            return sitemaster;
        }
 public LoginUserViewModel()
 {
     _service    = new CRMService();
     SubmitLogin = new DelegateCommand <object>(_loginUser);
 }
Пример #19
0
        //得到要回传的function字符串
        public string GetFunctionstringForView(string functionlist, int memberid, int ProductID, Hashtable htparm)
        {
            string temp = string.Empty;
            if (functionlist != null)
            {
                string[] list = functionlist.Split(',');

                CRMService crm = new CRMService();
                IList<ProductFunction> versionFunctionList = crm.GetFunctions(memberid, ProductID, htparm);
                int functioncount = 1;
                temp = "<div><input type='checkbox' id='checkall' />全选</div><table width='600px' border='1'cellpadding='6' cellspacing='1'><thead><tr>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind1' />会员管理</th><th align='left'><input type='checkbox' class='function kind' id='kind12' />项目与日程管理</th><th align='left'><input type='checkbox' class='function kind' id='kind2' />招标公告与信息</th>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind3' />招标数据库查询</th><th align='left'><input type='checkbox' class='function kind' id='kind4' />招标管理与助手</th>"
                       + "</tr></thead><tbody><tr>";

                temp += "<td align='left'>";
                string html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 1);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind1");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";

                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 12);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind12");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";

                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 2);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind2");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 3);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind3");
                    functioncount++;
                }

                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 4);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind4");
                    functioncount++;
                }
                temp += html;
                temp += "</td></tr></tbody></table>";

                temp += "<table width='600px' border='1'cellpadding='6' cellspacing='1'><thead><tr><th width='180px' align='left'><input type='checkbox' class='function kind' id='kind5' />数据分析与报告</th>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind6' />模拟评标与竞价</th><th align='left'><input type='checkbox' class='function kind' id='kind7' />专业数据库查询</th>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind8' />辅助数据库查询</th></tr></thead><tbody><tr>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 5);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind5");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 6);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind6");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 7);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind7");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 8);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDictEx(list, functioncount, func, "kind8");
                    functioncount++;
                }
                temp += html;
                temp += "</td></tr></tbody></table>";
            }
            else
            {
                CRMService crm = new CRMService();
                IList<ProductFunction> versionFunctionList = crm.GetFunctions(memberid, ProductID, htparm);
                int functioncount = 1;
                temp = "<div><input type='checkbox' id='checkall' />全选</div><table width='600px' border='1'cellpadding='6' cellspacing='1'><thead><tr>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind1' />会员管理</th><th align='left'><input type='checkbox' class='function kind' id='kind12' />项目与日程管理</th><th align='left'><input type='checkbox' class='function kind' id='kind2' />招标公告与信息</th>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind3' />招标数据库查询</th><th align='left'><input type='checkbox' class='function kind' id='kind4' />招标管理与助手</th>"
                       + "</tr></thead><tbody><tr>";

                temp += "<td align='left'>";
                string html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 1);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind1");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";

                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 12);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind12");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";

                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 2);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind2");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 3);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind3");
                    functioncount++;
                }

                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 4);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind4");
                    functioncount++;
                }
                temp += html;
                temp += "</td></tr></tbody></table>";

                temp += "<table width='600px' border='1'cellpadding='6' cellspacing='1'><thead><tr><th width='180px'align='left'><input type='checkbox' class='function kind' id='kind5' />数据分析与报告</th>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind6' />模拟评标与竞价</th><th align='left'><input type='checkbox' class='function kind' id='kind7' />专业数据库查询</th>"
                       + "<th align='left'><input type='checkbox' class='function kind' id='kind8' />辅助数据库查询</th></tr></thead><tbody><tr>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 5);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind5");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 6);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind6");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 7);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind7");
                    functioncount++;
                }
                temp += html;
                temp += "</td>";
                temp += "<td align='left'>";
                html = string.Empty;
                versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 8);
                foreach (ProductFunction func in versionFunctionList)
                {

                    html += GetDict(functioncount, func, "kind8");
                    functioncount++;
                }
                temp += html;
                temp += "</td></tr></tbody></table>";
            }
            return temp;
        }
Пример #20
0
        //会员状态action
        public ActionResult UserStatus()
        {
            Dictionary<string, string> sitemaster = GetSiteMaster();
            ViewData["SiteMaster"] = sitemaster;
            if(CurrentUserInfo!=null)
            {
                    int userid = Int32.Parse(CurrentUserInfo.UserID);
                    IDictionary dict = QueryUserStatus(userid);
                    if (dict != null)
                    {
                        dict["Memberlevel"] = new CRMService().GetUserMemberLevel(Int32.Parse(CurrentUserInfo.UserID)).ToString();
                        dict["PayStatus"] = GetUserS(Int32.Parse(dict["PayStatus"].ToString()));
                        ViewData["UserStatus"] = dict;

                    }
            }
            ViewData["titlename"] = "用户状态";
                return View();
        }
Пример #21
0
        public List <Folder> GetFolders(ISiteSetting siteSetting, Folder folder, int[] includedFolderTypes)
        {
            ICRMService crmService = new CRMService();

            return(crmService.GetFolders(siteSetting, folder, includedFolderTypes));
        }
 public PackagePageViewModel()
 {
     _service   = new CRMService();
     SubmitSave = new DelegateCommand(SaveNewPackage);
     Load();
 }
Пример #23
0
        public Folder GetFolder(ISiteSetting siteSetting, BasicFolderDefinition folderDefinition)
        {
            ICRMService spService = new CRMService();

            return(null);
        }
Пример #24
0
        public Folder GetWorkflowFolder(ISiteSetting siteSetting, Sobiens.Connectors.Entities.Folder itemFolder, string itemUrl)
        {
            ICRMService spService = new CRMService();

            return(null);
        }
Пример #25
0
        public List <Folder> GetFolders(ISiteSetting siteSetting, Folder folder)
        {
            ICRMService spService = new CRMService();

            return(null);
        }
Пример #26
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     CRMService.GetService();
 }
Пример #27
0
        //得到要给View端的function字符串
        public Dictionary<string, string> GetFunctionstringForView(int userid,string functionlist, int memberid, int ProductID)
        {
            string html = string.Empty;
            string[] list = functionlist.Split(',');

            CRMService crm = new CRMService();
            Hashtable htparm = new Hashtable();
            htparm["MemberLevel"] = (int)crm.GetUserMemberLevel(userid);
            //IList<ProductFunction> versionFunctionList = crm.GetFunctions(memberid, ProductID, htparm);
            int functioncount = 1;
            Dictionary<string, string> functiondict = new Dictionary<string, string>();

            IList<ProductFunction>  versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 1);
            foreach (ProductFunction func in versionFunctionList)
            {

                html += GetDict(functioncount, func, "kind1");
                functioncount++;
            }
            functiondict.Add("kind1", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 2);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind2");
                        functioncount++;
                    }
                    functiondict.Add("kind2", html);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind12");
                        functioncount++;
                    }
                    functiondict.Add("kind12", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 3);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind3");
                        functioncount++;
                    }
                    functiondict.Add("kind3", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 4);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind4");
                        functioncount++;
                    }
                    functiondict.Add("kind4", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 5);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind5");
                        functioncount++;
                    }
                    functiondict.Add("kind5", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 6);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind6");
                        functioncount++;
                    }
                    functiondict.Add("kind6", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 7);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind7");
                        functioncount++;
                    }
                    functiondict.Add("kind7", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 8);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDictEx(list,functioncount, func, "kind8");
                        functioncount++;
                    }
                    functiondict.Add("kind8", html);
            return functiondict;
        }
Пример #28
0
        public ActionResult ChildUser(FormCollection collection)
        {
            Dictionary<string, string> sitemaster = GetSiteMaster();
            ViewData["SiteMaster"] = sitemaster;

            int userid = Int32.Parse(CurrentUserInfo.UserID);
            MemberUserInfo mui=new MemberUserInfoDao().Find(userid);
            int memberid = mui.MemberID;
            CRMService crm = new CRMService();
            int memberlevel=(int)crm.GetUserMemberLevel(userid);
            if (CurrentUserInfo != null)
            {
                if (collection.Count == 0)
                {
                    ViewData["Name"] = CurrentUserInfo.UserName;
                    //获得初始的功能列表

                    Hashtable htparm = new Hashtable();
                    htparm["MemberLevel"] = memberlevel;
                    //IList<ProductFunction> versionFunctionList = crm.GetFunctions(memberid, ProductID,htparm);
                    //string functionlist = string.Empty;
                    Dictionary<string, string> functiondict = new Dictionary<string, string>();
                    int functioncount = 1;

                    string html = string.Empty;
                    IList<ProductFunction> versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm,1);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind1");
                        functioncount++;
                    }
                    functiondict.Add("kind1", html);

                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 12);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind12");
                        functioncount++;
                    }
                    functiondict.Add("kind12", html);

                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 2);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind2");
                        functioncount++;
                    }
                    functiondict.Add("kind2", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 3);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind3");
                        functioncount++;
                    }
                    functiondict.Add("kind3", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 4);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind4");
                        functioncount++;
                    }
                    functiondict.Add("kind4", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 5);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind5");
                        functioncount++;
                    }
                    functiondict.Add("kind5", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 6);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind6");
                        functioncount++;
                    }
                    functiondict.Add("kind6", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 7);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind7");
                        functioncount++;
                    }
                    functiondict.Add("kind7", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 8);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind8");
                        functioncount++;
                    }
                    functiondict.Add("kind8", html);
                    html = string.Empty;
                    ViewData["Function"] = functiondict;
                    ViewData["Max"] = "";
                }
                else
                {

                    bool IsAdmin = new MemberUserInfoDao().IsAdmin(userid);
                    if (!IsAdmin)
                    {
                        ViewData["Admin"] = IsAdmin;
                        ViewData["Function"] = "";
                        ViewData["Max"] = "";
                        return View();
                    }
                    else
                    {
                        //检查是否超过规定的子账户数
                        Hashtable htp=new Hashtable();
                        htp["MemberID"] = memberid;
                        int maxchildcount = 0;
                        int childusercount = CRMMapper.Get().QueryForObject<int>("MemberUserInfo.ChildUserCount", htp);
                        if (CRMMapper.Get().QueryForObject<int>("SpecialChild.getcount", memberid) > 0)
                        {
                            maxchildcount = CRMMapper.Get().QueryForObject<int>("SpecialChild.getchildcount", memberid);
                        }
                        else
                        {
                        maxchildcount=GetMaxCount(memberlevel);
                        }
                        if (childusercount >= maxchildcount)
                        {
                            ViewData["Max"] = "对不起,您的子账户数超过了您的会员等级规定的子账户数!";
                        }
                        else
                        {
                            UserModel newuser = new UserModel();
                            newuser.Username = collection["UserName"];
                            newuser.Password = collection["Password"];
                            newuser.Email = "";

                            /*if (!MembershipService.CheckValidateCode(collection["ValidateCode"]))
                            {
                                ViewData["Name"] = CurrentUserInfo.UserName;
                                ViewData["UserInfo"] = collection["UserName"];
                                ViewData["Validatecode"] = "False";
                                return View();
                            }*/
                            if (!MembershipService.UserIsExists(newuser.Username))
                            {
                                MembershipService.CreateNewUser(newuser);
                                MemberUserInfo newMember = new MemberUserInfo();
                                int tempuserid = MembershipService.GetUserID(collection["UserName"]);
                                newMember.UserID = tempuserid;
                                newMember.MemberID = memberid;
                                newMember.Name = collection["Name"];
                                newMember.IsMemberAdmin = 0;
                                newMember.Mobile = collection["Mobile"];
                                newMember.Status = 1;
                                new MemberUserInfoDao().Insert(newMember);

                                //插入子账户功能表
                                ChildUserFunction newchildfunc = new ChildUserFunction();
                                newchildfunc.UserID = tempuserid;
                                newchildfunc.ProductID = ProductID;
                                newchildfunc.FunctionIDList = GetFunctionstring(collection);
                                new ChildUserFunctionDao().Insert(newchildfunc);
                                ViewData["Function"] = GetFunctionstringForView(userid, newchildfunc.FunctionIDList, memberid, ProductID);
                                ViewData["PostExist"] = "False";
                                ViewData["ChildUser"] = "******";
                                ViewData["Max"] = "";
                            }
                            else
                            {
                                ViewData["PostExist"] = "True";
                                ViewData["Max"] = "";
                            }

                        }

                            ViewData["IsExists"] = false;
                            ViewData["Admin"] = IsAdmin;
                            ViewData["Name"] = CurrentUserInfo.UserName;
                            ViewData["UserInfo"] = collection["UserName"];
                            ViewData["RealName"] = collection["Name"];
                            ViewData["Mobile"] = collection["Mobile"];
                    }
                }

            }
            ViewData["titlename"] = "子账户新增";
            return View();
        }
Пример #29
0
 public JsonResult Rights(string UserName)
 {
     //得到子账户ID
     int userid = MembershipService.GetUserID(UserName);
     //得到子账户functionlist
     string functionlist = FindFunctionlist(userid, productid);
     //得到企业ID
     int memberid = new MemberUserInfoDao().Find(userid).MemberID;
     Hashtable htparm = new Hashtable();
     CRMService crm = new CRMService();
     htparm["MemberLevel"] = (int)crm.GetUserMemberLevel(userid);
     string result = GetFunctionstringForView(functionlist, memberid, productid, htparm);
     return this.Json(result);
 }
Пример #30
0
        private ValidationResults ValidateManagedSolutionComponents()
        {
            ValidationResults results = new ValidationResults();

            // export the solution as managed and extract it to get the customizations xml
            ExportSolutionRequest exportRequest = new ExportSolutionRequest();

            exportRequest.Managed      = true;
            exportRequest.SolutionName = Solution.UniqueName;
            OnValidatorProgress?.Invoke(this, new ProgressEventArgs("Exporting solution as managed"));
            ExportSolutionResponse managedResponse = CRMService.Execute(exportRequest) as ExportSolutionResponse;

            if (managedResponse != null)
            {
                try
                {
                    string zipFileName         = Solution.UniqueName + ".zip";
                    string customiationXmlPath = Constants.APP_DATA_TEMP_DIRECTOY_PATH + "\\customizations.xml";
                    string zipPath             = Constants.APP_DATA_TEMP_DIRECTOY_PATH + zipFileName;

                    // cleanup an existing directory files
                    if (Directory.Exists(Constants.APP_DATA_TEMP_DIRECTOY_PATH))
                    {
                        Directory.Delete(Constants.APP_DATA_TEMP_DIRECTOY_PATH, true);
                    }

                    // recreate the directory
                    if (!Directory.Exists(Constants.APP_DATA_TEMP_DIRECTOY_PATH))
                    {
                        Directory.CreateDirectory(Constants.APP_DATA_TEMP_DIRECTOY_PATH);
                    }

                    // write the managed solution as a zip file in the directory
                    OnValidatorProgress?.Invoke(this, new ProgressEventArgs("Saving Managed Solution"));
                    File.WriteAllBytes(zipPath, managedResponse.ExportSolutionFile);

                    // extract the zip file to get the customizations.xml file content
                    OnValidatorProgress?.Invoke(this, new ProgressEventArgs("Extracting Managed Solution"));
                    ZipFile.ExtractToDirectory(zipPath, Constants.APP_DATA_TEMP_DIRECTOY_PATH);


                    //at this point customization.xml file should be ready, load it into an xdocument object
                    if (File.Exists(customiationXmlPath))
                    {
                        OnValidatorProgress?.Invoke(this, new ProgressEventArgs("Checking the Customization File"));

                        XDocument customizationsXml = XDocument.Load(customiationXmlPath);
                        results.AddResultSet(CheckAttributes(customizationsXml));
                        results.AddResultSet(CheckViews(customizationsXml));
                        results.AddResultSet(CheckForms(customizationsXml));
                    }
                }

                catch (IOException ioEx)
                {
                    // fire an error to be catched by whoever is listening to the OnValidationError Event
                    OnValidatorError?.Invoke(this, new ErrorEventArgs(ioEx));
                    throw ioEx;
                }
                catch (Exception ex)
                {
                    OnValidatorError?.Invoke(this, new ErrorEventArgs(ex));
                    throw ex;
                }
            }
            return(results);
        }
Пример #31
0
        public bool ProcessBulkRecordDeletion(string environmentSpace, out string errorMsg)
        {
            errorMsg = string.Empty;
            IOrganizationService service = default(IOrganizationService);

            try
            {
                var repAct = new RepositorService();

                //make CRM Connection
                var crmCnct   = new CRMConnection();
                var connected = crmCnct.CreateCRMConnection(out service, environmentSpace, out errorMsg);

                if (!connected)
                {
                    errorMsg = $"No CRM connection established. Please review the URL and Credentials.";
                    return(false);
                }

                Trace.WriteLine("Program started; Record deletion initiated.");

                //Get Config data list
                var cnfigServ = new ConfigurationService();
                List <KeyValuePair <string, int> > config = cnfigServ.GetConfigValues(out errorMsg);

                if (config == null || config == default(List <KeyValuePair <string, int> >))
                {
                    errorMsg = $"Configuration list has returned no data. Program can  not continue.";
                    return(false);
                }

                //get case types list
                var crmInput = new CRMService();
                List <KeyValuePair <Guid, string> > caseTypes = crmInput.GetCaseTypeList(service, out errorMsg);

                if (caseTypes == null || caseTypes == default(List <KeyValuePair <Guid, string> >))
                {
                    errorMsg = $"Case type list comprised of CRM case types contains no data.";
                    return(false);
                }

                // compile config with CRM case type ID's
                List <KeyValuePair <Guid, int> > compiledCaseTypeList = crmInput.MergeCRMCaseTypesWithConfig(caseTypes, config, out errorMsg);

                if (compiledCaseTypeList == null || compiledCaseTypeList == default(List <KeyValuePair <Guid, int> >))
                {
                    errorMsg = $"The comprised list of case type ID's and configuration value amounts contains no data.";
                    return(false);
                }

                //get case count values from config, fetch that many cases of x case type
                EntityCollection protectedCases = crmInput.GetProtectedCases(service, compiledCaseTypeList, out errorMsg);

                if (protectedCases == null || protectedCases == default(EntityCollection))
                {
                    errorMsg = $"The collection of protected cases has returned containing no data.";
                    return(false);
                }

                // bulk update protected cases
                var updateResponse = repAct.BulkUpdateProtectedCases(service, protectedCases, out errorMsg);

                if (!updateResponse)
                {
                    errorMsg = $"There was an error whilst updating all protected cases.";
                    return(false);
                }

                //bulk delete unflagged cases
                var recordsDeleted = crmInput.CreateBulkCaseDeletionJob(service, out errorMsg);

                if (!recordsDeleted)
                {
                    errorMsg = $"CRM Bulk Delete for cases message was unsuccessfully sent to CRM.";
                    return(false);
                }

                //bulk delete completed system jobs
                var systemJobsComplete = crmInput.CreateSystemJobDeletionJob(service, out errorMsg);

                if (!systemJobsComplete)
                {
                    errorMsg = $"CRM Bulk Delete system jobs was unsuccessfully sent to CRM.";
                    return(false);
                }

                Trace.WriteLine("End");
                return(true);
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                errorMsg = e.Message;
                Trace.WriteLine(e.Message);
                return(false);
            }
        }