Exemplo n.º 1
0
        /// <summary>
        /// 获取开奖未读消息
        /// </summary>
        private void GetNoReadWinMsg()
        {
            var source = this.mMessageService.RefUserMessage(LoginUserId.ToString());

            //每次最多取5条数据
            if (null != source && source.Count() > 0)
            {
                string updateReadIds = "";
                foreach (var s in source)
                {
                    updateReadIds += s.Id + ",";
                }
                if (!string.IsNullOrEmpty(updateReadIds))
                {
                    updateReadIds = updateReadIds.Substring(0, updateReadIds.Length - 1);
                    //修改为已读
                    this.mMessageService.UpdateReadMessgae(updateReadIds);
                }
                AppGlobal.RenderResult <List <Message> >(ApiCode.Success, source);
            }
            else
            {
                AppGlobal.RenderResult(ApiCode.Fail);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 展示我的任务工作列表
        /// </summary>
        public void LoadMyTaskWorkList(HttpContext context)
        {
            QueryCommonBLL bll            = new QueryCommonBLL();
            var            taskResultPara = bll.GetResultParaSelect(LoginUserId, 265);
            QueryParaDto   taskQueryPara  = new QueryParaDto();

            taskQueryPara.query_params = new List <Para>();
            taskQueryPara.query_params.Add(new Para()
            {
                id = 3573, value = LoginUserId.ToString()
            });
            taskQueryPara.query_type_id = (int)QueryType.MyWorkListTask;
            taskQueryPara.para_group_id = 265;
            var taskQueryResult = bll.GetResult(LoginUserId, taskQueryPara);

            System.Text.StringBuilder thisHtml = new System.Text.StringBuilder();
            if (taskQueryResult != null && taskQueryResult.result != null)
            {
                foreach (var rslt in taskQueryResult.result)
                {
                    // DisabledState 不计时 添加此状态禁用

                    var id = "";
                    if (taskResultPara != null && taskResultPara.Count > 0)
                    {
                        var idPara = taskResultPara.FirstOrDefault(_ => _.type == (int)EMT.DoneNOW.DTO.DicEnum.QUERY_RESULT_DISPLAY_TYPE.ID);
                        if (idPara != null)
                        {
                            id = rslt[idPara.name].ToString();
                        }
                        thisHtml.AppendFormat($"<div class='WorkListItem' data-task-id='{id}'><div class='Left'  onclick=\"PageNewOpenTask('{id}')\"><div class='WorkListLineItemDetailsContainer'>");
                        foreach (var para in taskResultPara)
                        {
                            if (para.type == (int)EMT.DoneNOW.DTO.DicEnum.QUERY_RESULT_DISPLAY_TYPE.ID)
                            {
                                continue;
                            }
                            thisHtml.Append("<p>" + rslt[para.name] + "</p>");
                        }
                        thisHtml.AppendFormat("</div></div><div class='Right'><div class='WorkListItemButtons'><div class='WorkListClose Icon' onclick=\"NewOpenTask('{0}')\"></div><div class='WorkListArrow Icon' onclick=\"RemoveWorkListTicket('{0}','')\"></div></div><div class='Grip'></div></div></div>", id);
                    }
                }
            }
            context.Response.Write(thisHtml.ToString());
        }
Exemplo n.º 3
0
        public String ajax_UpdateUnitData(m_PowerUnit md)
        {
            ReturnAjaxInfo rAjaxResult = new ReturnAjaxInfo();

            a_PowerUnit ac = new a_PowerUnit()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunUpdateEnd r = ac.UpdateMaster(md, LoginUserId.ToString());

            if (!r.Result)
            {
                rAjaxResult.message = r.Message;
            }
            return(JsonConvert.SerializeObject(rAjaxResult, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 4
0
        public String ajax_MasterUpdataPassword(Password md)
        {
            ReturnAjaxInfo rAjaxResult = new ReturnAjaxInfo();

            ac = new a_Users()
            {
                Connection = getSQLConnection()
            };
            //修改
            md.id = LoginUserId;
            RunEnd HResult = ac.UpdateMasterPassword(md, LoginUserId.ToString());

            rAjaxResult    = HandleResultAjaxFiles(HResult, Resources.Res.Data_Update_Success);
            rAjaxResult.id = md.id;
            return(JsonConvert.SerializeObject(rAjaxResult, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 5
0
        private async Task <StorageFolder> GetEnsureVideoFolder()
        {
            if (_DownloadFolder == null)
            {
                try
                {
                    // 既にフォルダを指定済みの場合
                    if (Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.ContainsItem(FolderAccessToken))
                    {
                        _DownloadFolder = await Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.GetFolderAsync(FolderAccessToken);

                        CurrentFolderAccessToken = FolderAccessToken;
                    }
                }
                catch (FileNotFoundException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    //					Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Remove(FolderAccessToken);
                    Debug.WriteLine(ex.ToString());
                }
            }

            // 旧バージョン利用ユーザーが新バージョンを利用しても問題なくDLフォルダにアクセスできるようにする
            if (_DownloadFolder == null && Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.ContainsItem(LoginUserId.ToString()))
            {
                var token = LoginUserId.ToString();
                _DownloadFolder = await Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.GetFolderAsync(token);

                CurrentFolderAccessToken = token;
            }

            return(_DownloadFolder);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 展示我的工单工作列表
        /// </summary>
        public void LoadMyTicketWorkList(HttpContext context)
        {
            QueryCommonBLL bll = new QueryCommonBLL();
            var            ticketResultPara = bll.GetResultParaSelect(LoginUserId, 264);// groupId
            QueryParaDto   tickeQueryPara   = new QueryParaDto();

            tickeQueryPara.query_params = new List <Para>();
            tickeQueryPara.query_params.Add(new Para()
            {
                id = 3572, value = LoginUserId.ToString()
            });
            tickeQueryPara.query_type_id = (int)QueryType.MyWorkListTicket;
            tickeQueryPara.para_group_id = 264;
            var ticketQueryResult = bll.GetResult(LoginUserId, tickeQueryPara);

            System.Text.StringBuilder thisHtml = new System.Text.StringBuilder();
            var thisWorkList = new DAL.sys_work_list_dal().GetByResId(LoginUserId);
            var isJiShi      = ""; // 页面打开工单时,是否计时

            if (thisWorkList != null && thisWorkList.auto_start == 1)
            {
                isJiShi = "JiShi";
            }
            if (ticketQueryResult != null && ticketQueryResult.result != null)
            {
                var stDal = new DAL.sdk_task_dal();
                foreach (var rslt in ticketQueryResult.result)
                {
                    // DisabledState 不计时 添加此状态禁用

                    if (ticketResultPara != null && ticketResultPara.Count > 0)
                    {
                        var id     = "";
                        var idPara = ticketResultPara.FirstOrDefault(_ => _.type == (int)EMT.DoneNOW.DTO.DicEnum.QUERY_RESULT_DISPLAY_TYPE.ID);
                        if (idPara != null)
                        {
                            id = rslt[idPara.name].ToString();
                        }
                        if (id == "")
                        {
                            continue;
                        }
                        var thisTicket = stDal.FindNoDeleteById(long.Parse(id));
                        if (thisTicket == null)
                        {
                            continue;
                        }
                        var isDisabled = "";
                        if (thisTicket.status_id == (int)DicEnum.TICKET_STATUS.DONE)
                        {
                            isDisabled = "DisabledState";
                        }
                        thisHtml.AppendFormat($"<div class='WorkListItem' data-task-id='{id}'><div class='Left'  onclick=\"PageNewOpenTicket('{id}','{isJiShi}')\"><div class='StopwatchContainer {id}ThisWatch'><div class='StopwatchTime {isDisabled}'>{(!string.IsNullOrEmpty(isDisabled)?"--:--:--":"00:00:00")}</div><div class='StopwatchButton Play {isDisabled}'></div><div class='StopwatchButton Record {isDisabled}'></div><div class='StopwatchButton Stop {isDisabled}'></div></div><div class='WorkListLineItemDetailsContainer'>");
                        //ticketResultPara = ticketResultPara.Where(_=>_.type!= (int)EMT.DoneNOW.DTO.DicEnum.QUERY_RESULT_DISPLAY_TYPE.ID).Take(6).ToList();
                        foreach (var para in ticketResultPara)
                        {
                            if (para.type == (int)EMT.DoneNOW.DTO.DicEnum.QUERY_RESULT_DISPLAY_TYPE.ID)
                            {
                                continue;
                            }
                            thisHtml.Append("<p>" + rslt[para.name] + "</p>");
                        }
                        thisHtml.AppendFormat("</div></div><div class='Right'><div class='WorkListItemButtons'><div class='WorkListClose Icon' onclick=\"NewOpenTicket('{0}')\"></div><div class='WorkListArrow Icon' onclick=\"RemoveWorkListTicket('{0}','1')\"></div></div><div class='Grip'></div></div></div>", id);
                    }
                }
            }
            context.Response.Write(thisHtml.ToString());
        }
Exemplo n.º 7
0
        protected bool noTime = false;      // 可以不输入开始结束时间(根据系统设置进行判断)
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //  是否需要输入开始结束时间
                var isNeedTimeString = Request.QueryString["NoTime"];
                var noTimeSet        = new SysSettingBLL().GetSetById(SysSettingEnum.SDK_ENTRY_REQUIRED);
                if (!string.IsNullOrEmpty(isNeedTimeString))
                {
                    if (noTimeSet != null && noTimeSet.setting_value == "0")
                    {
                        noTime = true;
                    }
                }
                var callId = Request.QueryString["callId"];
                if (!string.IsNullOrEmpty(callId))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(callId));
                }
                thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
                var resList = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value as List <DictionaryEntryDto>;
                if (!IsPostBack)
                {
                    resource_id.DataTextField  = "show";
                    resource_id.DataValueField = "val";
                    var  entryProxySet = new SysSettingBLL().GetValueById(SysSettingEnum.SDK_ENTRY_PROXY);
                    bool isAgent       = false;
                    if (entryProxySet == ((int)DicEnum.PROXY_TIME_ENTRY.DISABLED).ToString())
                    {
                        if (resList != null && resList.Count > 0)
                        {
                            resList = resList.Where(_ => _.val == LoginUserId.ToString()).ToList();
                        }
                    }
                    else
                    {
                        var agentResList = new UserResourceBLL().GetAgentUser(LoginUserId, out isAgent);
                        if (agentResList != null && agentResList.Count > 0)
                        {
                            resList = (from a in agentResList
                                       select new DictionaryEntryDto()
                            {
                                val = a.id.ToString(), show = a.name
                            }).ToList();
                        }
                    }
                    resource_id.DataSource    = resList;
                    resource_id.SelectedValue = LoginUserId.ToString();
                    resource_id.DataBind();

                    var statusList = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value as List <DictionaryEntryDto>;
                    //statusList.Remove(statusList.FirstOrDefault(_=>_.val==((int)DicEnum.TICKET_STATUS.NEW).ToString()));
                    status_id.DataTextField  = "show";
                    status_id.DataValueField = "val";
                    status_id.DataSource     = statusList;
                    status_id.DataBind();


                    cost_code_id.DataTextField  = "name";
                    cost_code_id.DataValueField = "id";
                    cost_code_id.DataSource     = new d_cost_code_dal().GetCostCodeByWhere((int)DicEnum.COST_CODE_CATE.GENERAL_ALLOCATION_CODE);
                    cost_code_id.DataBind();

                    notify_id.DataTextField  = "name";
                    notify_id.DataValueField = "id";
                    notify_id.DataSource     = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.TICKET_TIME_ENTRY_CREATED_EDITED);
                    notify_id.DataBind();
                }

                var taskId = Request.QueryString["task_id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTask = new sdk_task_dal().FindNoDeleteById(long.Parse(taskId));
                }

                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisWorkEntry = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(id));
                    if (thisWorkEntry != null)
                    {
                        if (thisWorkEntry.approve_and_post_date != null || thisWorkEntry.approve_and_post_user_id != null)
                        {
                            Response.Write("<script>alert('审批提交的工时不可以更改!');window.close();</script>");
                            Response.End();
                        }

                        if (!resList.Any(_ => _.val == thisWorkEntry.create_user_id.ToString()))
                        {
                            Response.Write("<script>alert('系统设置不能代理操作!');window.close();</script>");
                            return;
                        }
                        if (thisWorkEntry.end_time == null && noTimeSet != null && noTimeSet.setting_value == "0")
                        {
                            noTime = true;
                        }
                        entryList = new sdk_work_entry_dal().GetBatchList(thisWorkEntry.batch_id);
                        isAdd     = false;
                        thisTask  = new sdk_task_dal().FindNoDeleteById(thisWorkEntry.task_id);
                        if (!IsPostBack)
                        {
                            resource_id.ClearSelection();
                            resource_id.SelectedValue  = ((long)thisWorkEntry.resource_id).ToString();
                            cost_code_id.SelectedValue = ((long)thisWorkEntry.cost_code_id).ToString();
                            // status_id.SelectedValue = ((long)thisWorkEntry.)
                            // thisTask  = new crm_account_dal().FindNoDeleteById(thisWorkEntry.);
                        }

                        if (thisWorkEntry.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisWorkEntry.contract_id);
                        }
                        if (!IsPostBack)
                        {
                            isBilled.Checked  = thisWorkEntry.is_billable == 0;
                            ShowOnInv.Checked = thisWorkEntry.show_on_invoice == 1;
                            if (isBilled.Checked)
                            {
                                ShowOnInv.Enabled = true;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('工时已被删除!')window.close();</script>");
                        Response.End();
                    }
                }
                #region 根据批次获取相关工时
                //var batchId = Request.QueryString["batchId"];
                //if (!string.IsNullOrEmpty(batchId))
                //{
                //    entryList = new sdk_work_entry_dal().GetBatchList(long.Parse(batchId));
                //    if(entryList!=null&& entryList.Count > 0)
                //    {
                //        thisWorkEntry = entryList[0];
                //        if (thisWorkEntry.approve_and_post_date != null || thisWorkEntry.approve_and_post_user_id != null)
                //        {
                //            Response.Write("<script>alert('审批提交的工时不可以更改!');window.close();</script>");
                //            Response.End();
                //        }

                //        if (!resList.Any(_ => _.val == thisWorkEntry.create_user_id.ToString()))
                //        {
                //            Response.Write("<script>alert('系统设置不能代理操作!')window.close();</script>");
                //            Response.End();
                //        }
                //        if (thisWorkEntry.end_time == null && noTimeSet != null && noTimeSet.setting_value == "0")
                //        {
                //            noTime = true;
                //        }
                //        entryList = new sdk_work_entry_dal().GetBatchList(thisWorkEntry.batch_id);
                //        isAdd = false;
                //        thisTask = new sdk_task_dal().FindNoDeleteById(thisWorkEntry.task_id);
                //        if (!IsPostBack)
                //        {
                //            resource_id.SelectedValue = ((long)thisWorkEntry.resource_id).ToString();
                //            cost_code_id.SelectedValue = ((long)thisWorkEntry.cost_code_id).ToString();
                //            // status_id.SelectedValue = ((long)thisWorkEntry.)
                //            // thisTask  = new crm_account_dal().FindNoDeleteById(thisWorkEntry.);

                //        }

                //        if (thisWorkEntry.contract_id != null)
                //        {
                //            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisWorkEntry.contract_id);
                //        }
                //        if (!IsPostBack)
                //        {
                //            isBilled.Checked = thisWorkEntry.is_billable == 0;
                //            ShowOnInv.Checked = thisWorkEntry.show_on_invoice == 1;
                //            if (isBilled.Checked)
                //            {
                //                ShowOnInv.Enabled = true;
                //            }
                //        }
                //    }
                //}
                #endregion
                if (thisTask != null)
                {
                    v_task      = new v_task_all_dal().FindById(thisTask.id);
                    thisProjetc = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                    if (thisProjetc != null)
                    {
                        thisAccount = new crm_account_dal().FindNoDeleteById(thisProjetc.account_id);
                        if (!IsPostBack)
                        {
                            status_id.SelectedValue = thisTask.status_id.ToString();
                        }
                    }
                }
                // 项目关联合同,并且合同中设置-工时录入需要输入开始结束时间
                if (thisProjetc != null && thisProjetc.contract_id != null)
                {
                    var thisCttContract = new ctt_contract_dal().FindNoDeleteById((long)thisProjetc.contract_id);
                    if (thisCttContract != null)
                    {
                        if (thisCttContract.timeentry_need_begin_end == 1)
                        {
                            noTime = false;
                        }
                    }
                }

                if (thisCall != null)
                {
                    showStartDate = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.start_time);
                    showEndDate   = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.end_time);
                }
                if (!string.IsNullOrEmpty(Request.QueryString["chooseDate"]))
                {
                    showStartDate = DateTime.Parse(Request.QueryString["chooseDate"]);
                    showEndDate   = DateTime.Parse(Request.QueryString["chooseDate"]);
                }
            }
            catch (Exception msg)
            {
                Response.Write($"<script>alert('{msg.Message}');window.close();</script>");
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var chooseDateString = Request.QueryString["chooseDate"];
                if (!string.IsNullOrEmpty(chooseDateString))
                {
                    chooseDate = DateTime.Parse(chooseDateString);
                }
                user = UserInfoBLL.GetUserInfo(GetLoginUserId());
                if (!string.IsNullOrEmpty(Request.QueryString["isSeven"]))
                {
                    isSeven = true;
                }
                if (!string.IsNullOrEmpty(Request.QueryString["isShowDetai"]))
                {
                    isShowDetai = true;
                }

                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(id));
                    if (thisProject != null)
                    {
                        taskList   = new sdk_task_dal().GetProTask(thisProject.id, " and type_id in (1807,1808,1812)");
                        proCalList = new pro_project_calendar_dal().GetCalByPro(thisProject.id);
                    }
                }
                if (!string.IsNullOrEmpty(Request.QueryString["isAll"]))
                {
                    isAll = true;
                }
                if (isAll)
                {
                    taskList = new sdk_task_dal().FindListBySql($"select* from sdk_task where delete_time = 0 and type_id in (1807,1808,1812)");
                    var ppDal = new DAL.pro_project_dal();
                    proCalList = new pro_project_calendar_dal().FindListBySql($"SELECT * from pro_project_calendar where delete_time = 0");
                    const string proLimitJson    = "{\"row\":\"7\",\"t1\":\"p\",\"col1\":\"0\",\"col2\":\"0\"}";
                    var          projectLimitSql = Convert.ToString(ppDal.GetSingle($"select f_rpt_getsql_limit('{proLimitJson}',{LoginUserId.ToString()})"));
                    projectList = ppDal.FindListBySql("select* from pro_project p where p.delete_time =0 " + projectLimitSql);
                }
            }
            catch (Exception msg)
            {
                Response.End();
            }
        }
Exemplo n.º 9
0
        private async Task CacheFolderMigration(StorageFolder newVideoFolder)
        {
            if (_DownloadFolder?.Path != newVideoFolder.Path)
            {
                // フォルダーの移行作業を開始

                // 現在あるダウンロードタスクは必ず終了させる必要があります
                MediaManager?.StopCacheDownload();

                // v0.4.0以降の移行処理
                if (_DownloadFolder != null)
                {
                    await MoveFiles(_DownloadFolder, newVideoFolder);
                }


                // v0.3.9以前 からの移行処理
                if (_DownloadFolder != null)
                {
                    var oldSaveFolder      = _DownloadFolder;
                    var oldVideoSaveFolder = (await oldSaveFolder.TryGetItemAsync("video")) as StorageFolder;
                    if (oldVideoSaveFolder != null)
                    {
                        var newVideoSaveFolder = newVideoFolder;
                        await MoveFiles(oldVideoSaveFolder, newVideoSaveFolder);
                    }

                    // DL/Hohoema/{Userid}/Fav/Feed の内容を AppData/Hohoema/LocalState/Feedに移動
                    var oldFavSaveFolder = (await oldSaveFolder.TryGetItemAsync("fav")) as StorageFolder;
                    if (oldFavSaveFolder != null)
                    {
                        var oldFeedSaveFolder = (await oldFavSaveFolder.TryGetItemAsync("feed")) as StorageFolder;
                        if (oldFeedSaveFolder != null)
                        {
                            await MoveFiles(oldFeedSaveFolder, await GetFeedDataFolder());
                        }
                    }
                }



                #region v0.3.3 からの移行処理


                // Note: v0.3.3以前にLocalFolderに作成されていたフォルダが存在する場合、そのフォルダの内容を
                // _DownlaodFolderに移動させます

                {
                    var oldVersionDataFolder = await GetLegacyUserDataFolder(LoginUserId.ToString());

                    if (oldVersionDataFolder != null)
                    {
                        var oldVideoSaveFolder = (await oldVersionDataFolder.TryGetItemAsync("video")) as StorageFolder;
                        if (oldVideoSaveFolder != null)
                        {
                            //						var newVideoSaveFolder = await newVideoFolder.CreateFolderAsync("video", CreationCollisionOption.OpenIfExists);
                            await MoveFiles(oldVideoSaveFolder, newVideoFolder);
                        }
                    }

                    // favの保存は v0.3.10 or v0.4.0からは廃止しています
                    //					var oldFavSaveFolder = (await oldVersionDataFolder.TryGetItemAsync("fav")) as StorageFolder;
                    //					if (oldFavSaveFolder != null)
                    {
//						var newFavSaveFolder = await newVideoFolder.CreateFolderAsync("fav", CreationCollisionOption.OpenIfExists);
//						await MoveFiles(oldFavSaveFolder, newFavSaveFolder);
                    }
                }

                #endregion


                try
                {
                    await MediaManager.OnCacheFolderChanged();
                }
                catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
            }

            _DownloadFolder = newVideoFolder;
        }
Exemplo n.º 10
0
        public IAsyncOperation <NiconicoSignInStatus> SignIn(string mailOrTelephone, string password)
        {
            return(AsyncInfo.Run <NiconicoSignInStatus>(async(cancelToken) =>
            {
                if (!Util.InternetConnection.IsInternet())
                {
                    NiconicoContext?.Dispose();
                    NiconicoContext = new NiconicoContext();
                    return NiconicoSignInStatus.Failed;
                }

                if (NiconicoContext != null &&
                    NiconicoContext.AuthenticationToken?.MailOrTelephone == mailOrTelephone &&
                    NiconicoContext.AuthenticationToken?.Password == password)
                {
                    return NiconicoSignInStatus.Success;
                }

                await SignOut();

                try
                {
                    await _SigninLock.WaitAsync();



                    var context = new NiconicoContext(new NiconicoAuthenticationToken(mailOrTelephone, password));

                    context.AdditionalUserAgent = HohoemaUserAgent;

                    LoginErrorText = "";

                    Debug.WriteLine("try login");

                    NiconicoSignInStatus result = NiconicoSignInStatus.Failed;
                    try
                    {
                        result = await context.SignInAsync();
                    }
                    catch
                    {
                        LoginErrorText = "サインインに失敗、再起動をお試しください";
                    }

                    UpdateServiceStatus(result);

                    NiconicoContext = context;

                    if (result == NiconicoSignInStatus.Success)
                    {
                        Debug.WriteLine("login success");


                        using (var loginActivityLogger = LoggingChannel.StartActivity("login process"))
                        {
                            loginActivityLogger.LogEvent("begin login process.");

                            var fields = new LoggingFields();

                            await Task.Delay(500);
                            try
                            {
                                loginActivityLogger.LogEvent("getting UserInfo.");
                                var userInfo = await NiconicoContext.User.GetInfoAsync();

                                LoginUserId = userInfo.Id;
                                IsPremiumUser = userInfo.IsPremium;

                                {
                                    try
                                    {
                                        var user = await NiconicoContext.User.GetUserDetail(LoginUserId.ToString());
                                        LoginUserName = user.Nickname;
                                        UserIconUrl = user.ThumbnailUri;

                                        OnPropertyChanged(nameof(LoginUserName));
                                        OnPropertyChanged(nameof(UserIconUrl));
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception("ユーザー名取得のフォールバック処理に失敗 + " + LoginUserId, ex);
                                    }
                                }

                                fields.AddString("user id", LoginUserId.ToString());
                                fields.AddString("user name", LoginUserName);
                                fields.AddBoolean("is premium", IsPremiumUser);

                                loginActivityLogger.LogEvent("[Success]:get UserInfo.", fields, LoggingLevel.Information);
                            }
                            catch (Exception ex)
                            {
                                LoginErrorText = $"ユーザー情報の取得に失敗しました。再起動をお試しください。({ex.Message})";

                                fields.AddString("mail", mailOrTelephone);
                                loginActivityLogger.LogEvent(LoginErrorText, fields, LoggingLevel.Warning);

                                NiconicoContext.Dispose();
                                NiconicoContext = new NiconicoContext();

                                return NiconicoSignInStatus.Failed;
                            }

                            fields.Clear();



                            Debug.WriteLine("user id is : " + LoginUserId);


                            // 0.4.0以前のバージョンからのログインユーザー情報の移行処理
                            try
                            {
                                await MigrateLegacyUserSettings(LoginUserId.ToString());
                            }
                            catch
                            {
                                LoginErrorText = "ユーザー設定の過去バージョンとの統合処理に失敗しました。";

                                return NiconicoSignInStatus.Failed;
                            }


                            try
                            {
                                Debug.WriteLine("initilize: fav");
                                loginActivityLogger.LogEvent("initialize user favorite");
                                FollowManager = await FollowManager.Create(this, LoginUserId);
                            }
                            catch
                            {
                                LoginErrorText = "お気に入り情報の取得に失敗しました。再起動をお試しください。";
                                Debug.WriteLine(LoginErrorText);
                                loginActivityLogger.LogEvent(LoginErrorText, fields, LoggingLevel.Error);
                                NiconicoContext.Dispose();
                                NiconicoContext = new NiconicoContext();
                                return NiconicoSignInStatus.Failed;
                            }

                            FollowManagerUpdater = BackgroundUpdater.RegistrationBackgroundUpdateScheduleHandler(
                                FollowManager,
                                "FollowManager",
                                label: "フォロー"
                                );


                            Debug.WriteLine("Login done.");
                            loginActivityLogger.LogEvent("[Success]: Login done");
                        }

                        // BG更新をスケジュール
                        UpdateAllComponent();

                        // 動画のキャッシュフォルダの選択状態をチェック
                        await(App.Current as App).CheckVideoCacheFolderState();


                        // サインイン完了
                        OnSignin?.Invoke();

                        // TODO: 途中だった動画のダウンロードを再開
                        // await MediaManager.StartBackgroundDownload();



                        // ニコニコサービスの裏で取得させたいので強制的に待ちを挟む
                        await Task.Delay(1000);
                    }
                    else
                    {
                        Debug.WriteLine("login failed");
                        NiconicoContext?.Dispose();
                        NiconicoContext = null;
                    }

                    return result;
                }
                finally
                {
                    _SigninLock.Release();
                }
            }));
        }
Exemplo n.º 11
0
 public Task <StorageFolder> GetCurrentUserDataFolder()
 {
     return(ApplicationData.Current.LocalFolder.CreateFolderAsync(LoginUserId.ToString(), CreationCollisionOption.OpenIfExists).AsTask());
 }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisBookMark = new IndexBLL().GetSingBook(Request.Url.LocalPath, LoginUserId);
            const string proLimitJson    = "{\"row\":\"7\",\"t1\":\"p\",\"col1\":\"0\",\"col2\":\"0\"}";
            var          projectLimitSql = Convert.ToString(ppDal.GetSingle($"select f_rpt_getsql_limit('{proLimitJson}',{LoginUserId.ToString()})"));


            myProjectList = ppDal.FindListBySql <pro_project>($"SELECT p.id,p.name from pro_project p where p.delete_time = 0 and p.owner_resource_id = {LoginUserId.ToString()} and p.status_id not in(1345,1352) " + projectLimitSql);
            //

            myTeamProjectList = ppDal.FindListBySql <pro_project>($"SELECT DISTINCT p.id,p.name from pro_project p INNER JOIN pro_project_team ppt on p.id =ppt.project_id where p.delete_time =0 and ppt.delete_time = 0 and ppt.resource_id ={LoginUserId.ToString()} and p.status_id not in(1345,1352) " + projectLimitSql);

            myDepProjectList = ppDal.FindListBySql <pro_project>($"SELECT p.id,p.name from pro_project p where p.delete_time = 0 and p.owner_resource_id = {LoginUserId.ToString()} and p.status_id not in(1345,1352) and p.department_id in ( SELECT DISTINCT department_id from sys_resource_department) " + projectLimitSql);

            // SELECT DISTINCT owner_resource_id from pro_project where delete_time =0 and owner_resource_id is not NULL
            var    priResIds = ppDal.GetRes($"SELECT DISTINCT owner_resource_id from pro_project p where p.delete_time =0 and p.owner_resource_id is not NULL " + projectLimitSql);
            var    otherIds  = ppDal.GetRes($"SELECT DISTINCT ppt.resource_id from pro_project p INNER JOIN pro_project_team ppt on p.id =ppt.project_id where p.delete_time =0 and ppt.delete_time = 0 and ppt.resource_id is not null " + projectLimitSql);
            string ids       = string.Empty;

            if (priResIds != null && priResIds.Count > 0)
            {
                priResIds.ForEach(_ => { ids += _.ToString() + ','; });
            }
            if (otherIds != null && otherIds.Count > 0)
            {
                otherIds.ForEach(_ => { ids += _.ToString() + ','; });
            }
            if (!string.IsNullOrEmpty(ids))
            {
                ids     = ids.Substring(0, ids.Length - 1);
                resList = new DAL.sys_resource_dal().GetListByIds(ids);
                if (resList != null && resList.Count > 0)
                {
                    resList = resList.Distinct().ToList();
                }
            }

            openIssueCount = Convert.ToInt32(ppDal.GetSingle("SELECT count(1) from sdk_task st INNER join pro_project p on st.project_id = p.id  where st.delete_time = 0 and p.delete_time = 0 and st.is_project_issue=1 and st.status_id <> 1894 and p.status_id <> 1352 "));
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisBookMark = new IndexBLL().GetSingBook(Request.Url.LocalPath, LoginUserId);
            // 今天生成的待办数量
            // 过期的待办
            // 打开的指派给其他人的待办
            // sys_resource_sales_quota
            //  需要更新的商机
            // 昨天的工单 | 今天的工单
            queryType = Request.QueryString["queryType"];
            if (string.IsNullOrEmpty(queryType))
            {
                queryType = "R|" + LoginUserId.ToString();
            }
            var queryArr = queryType.Split('|');

            if (queryArr[0] == "T" && queryArr.Count() == 2)
            {
                terrId = long.Parse(queryArr[1]);
            }
            else if (queryArr[0] == "R" && queryArr.Count() == 2)
            {
                resourceId = long.Parse(queryArr[1]);
            }
            else
            {
                resourceId = LoginUserId;
            }
            // 今天的开始结束时间
            var start = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + "00:00:00");
            var end   = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + "23:59:59");
            // 昨天的开始结束时间
            var yesStart = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " " + "00:00:00");
            var yesEnd   = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " " + "23:59:59");
            var timeNow  = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            // 本月的开始结束时间
            var monthStart = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM") + "-01 " + "00:00:00");
            var monthDay   = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
            var monthEnd   = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM") + "-" + monthDay.ToString() + " " + "23:59:59");

            string accClassWhere = "";

            var aa    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            var caDal = new DAL.com_activity_dal();
            // 客户: {"row":"1","t1":"ca","col1":"1,2,3","col2":"1,2"}
            var accLimitJson = "{\"row\":\"1\",\"t1\":\"ca\",\"col1\":\"1,2,3\",\"col2\":\"1,2\"}";
            // 商机: {"row":"2","t1":"o","col1":"11"}
            var oppoLimtJson = "{\"row\":\"2\",\"t1\":\"cp\",\"col1\":\"11\"}";

            var accountLimitSql = Convert.ToString(caDal.GetSingle($"select f_rpt_getsql_limit('{accLimitJson}',{LoginUserId.ToString()})"));
            var oppoLimitSql    = Convert.ToString(caDal.GetSingle($"select f_rpt_getsql_limit('{oppoLimtJson}',{LoginUserId.ToString()})"));

            if (terrId != null)
            {
                var terResList = new DAL.sys_resource_territory_dal().GetByTerrId((long)terrId);
                if (terResList != null && terResList.Count > 0)
                {
                    terResList.ForEach(_ => { terResIds += _.resource_id.ToString() + ","; });
                }
                if (!string.IsNullOrEmpty(terResIds))
                {
                    terResIds = terResIds.Substring(0, terResIds.Length - 1);
                }
                string terrResWhere = "";
                if (terrId != 0)
                {
                    if (!string.IsNullOrEmpty(terResIds))
                    {
                        terrResWhere = $" and ca.resource_id in({terResIds})";
                    }
                    else
                    {
                        terrResWhere = $" and ca.resource_id in('')";
                    }
                }

                #region 摘要查询数量


                overdueTodoCount    = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from com_activity act INNER JOIN crm_account ca on act.account_id = ca.id  where act.cate_id = {(int)DTO.DicEnum.ACTIVITY_CATE.TODO} and ca.delete_time = 0 and act.delete_time = 0  and act.status_id = {(int)DTO.DicEnum.ACTIVITY_STATUS.NOT_COMPLETED} and act.end_date<={timeNow} " + accountLimitSql + (terrId == 0 ? $"" : $" and act.resource_id in({(string.IsNullOrEmpty(terResIds) ? "''" : terResIds)})")));
                myAsignToOtherCount = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from com_activity act INNER JOIN crm_account ca on act.account_id = ca.id  where act.cate_id = {(int)DTO.DicEnum.ACTIVITY_CATE.TODO} and ca.delete_time = 0 and act.delete_time = 0 " + accountLimitSql + (terrId == 0?$" and act.create_user_id <> act.resource_id" : $" and act.create_user_id in({(string.IsNullOrEmpty(terResIds)?"''": terResIds)})")));

                needEditOppoCount = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id  where cp.delete_time = 0  and projected_close_date < '{DateTime.Now.ToString("yyyy-MM-dd")}' and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.ACTIVE} " + accountLimitSql + oppoLimitSql + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and cp.resource_id in('')" : $" and cp.resource_id in({terResIds})"))));
                yesTicketCount    = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) FROM sdk_task st INNER JOIN crm_account ca on st.account_id = ca.id where st.type_id in (1809,1818)  and st.create_time <={Tools.Date.DateHelper.ToUniversalTimeStamp(yesEnd)} and st.create_time>={Tools.Date.DateHelper.ToUniversalTimeStamp(yesStart)}" + (string.IsNullOrEmpty(terResIds) ? "" : $" and ca.resource_id in({terResIds})")));

                todayTicketCount = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) FROM sdk_task st INNER JOIN crm_account ca on st.account_id = ca.id where st.type_id in (1809,1818)  and st.create_time <={Tools.Date.DateHelper.ToUniversalTimeStamp(end)} and st.create_time>={Tools.Date.DateHelper.ToUniversalTimeStamp(start)}" + terrResWhere));

                monthLostOppo = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id where cp.delete_time = 0 and actual_closed_time <= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} and actual_closed_time >= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.LOST} " + accountLimitSql + oppoLimitSql + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and cp.resource_id in('')" : $" and cp.resource_id in({terResIds})"))));

                //monthClosedOppo = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity where delete_time = 0 and actual_closed_time <= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} and actual_closed_time >= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.CLOSED}" + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? "''" : $" and resource_id in({terResIds})"))));

                monthCloseOppo = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id  where cp.delete_time = 0 and projected_close_date <= {monthEnd.ToString("yyyy-MM-dd")} and projected_close_date >= {monthStart.ToString("yyyy-MM-dd")} and cp.status_id ={(int)DicEnum.OPPORTUNITY_STATUS.ACTIVE} " + accountLimitSql + oppoLimitSql + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and cp.resource_id in('')" : $" and cp.resource_id in({terResIds})"))));

                monthClosedOppoList = caDal.FindListBySql <crm_opportunity>($"SELECT * from crm_opportunity  cp inner join crm_account ca on cp.account_id = ca.id  where cp.delete_time = 0 and actual_closed_time <= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} and actual_closed_time >= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and cp.status_id ={(int)DicEnum.OPPORTUNITY_STATUS.CLOSED} " + accountLimitSql + " " + oppoLimitSql + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and cp.resource_id in('')" : $" and cp.resource_id in({terResIds})")));
                #endregion

                accountCount      = Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account ca where delete_time = 0 " + accountLimitSql + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and resource_id in('')" : $" and resource_id in({terResIds})"))));
                activeOppoList    = caDal.FindListBySql <crm_opportunity>($"SELECT * from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id  where cp.delete_time = 0 and cp.status_id = {(int)DicEnum.OPPORTUNITY_STATUS.ACTIVE} " + accountLimitSql + " " + oppoLimitSql + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and cp.resource_id in('')" : $" and cp.resource_id in({terResIds})")));
                newOppoMonthCount = Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id  where cp.delete_time = 0 and cp.create_time>={Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and cp.create_time<={Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} " + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and cp.resource_id in('')" : $" and cp.resource_id in({terResIds})"))));

                //
                updateOppoNoteCount = Convert.ToInt32(caDal.GetSingle($"SELECT * from com_activity ca INNER JOIN crm_opportunity co on ca.opportunity_id = co.id where ca.action_type_id = {(int)DicEnum.ACTIVITY_TYPE.OPPORTUNITYUPDATE} and ca.cate_id = {(int)DicEnum.ACTIVITY_CATE.NOTE} and ca.delete_time = 0 and co.delete_time = 0 and ca.create_time>{Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and ca.create_time<={Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} " + (terrId == 0 ? "" : (string.IsNullOrEmpty(terResIds) ? " and co.resource_id in('')" : $" and co.resource_id in({terResIds})"))));
                if (terrId == 0)
                {
                    if (terrList != null && terrList.Count > 0)
                    {
                        terrList.ForEach(_ => {
                            terrAccDic.Add(_.id, Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account where delete_time = 0 and territory_id =" + _.id.ToString())));
                        });
                    }
                }
                else
                {
                    terrAccDic.Add((long)terrId, Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account where delete_time = 0 and territory_id =" + terrId.ToString())));
                }
                if (terrId != 0)
                {
                    if (!string.IsNullOrEmpty(terResIds))
                    {
                        accClassWhere = " " + accountLimitSql + $" and resource_id in({terResIds})";
                    }
                    else
                    {
                        accClassWhere = $" and resource_id in('')";
                    }
                }
                if (!string.IsNullOrEmpty(terResIds))
                {
                    resQuotaList = new DAL.sys_resource_sales_quota_dal().GetQuotaByResIds(terResIds, DateTime.Now.Year, DateTime.Now.Month);
                }
            }
            else if (resourceId != null)
            {
                string terIds  = ""; // 该负责人下的所有区域的Id 集合
                var    terList = new DAL.sys_resource_territory_dal().GetListByResourceId((long)resourceId);
                if (terList != null && terList.Count > 0)
                {
                    terList.ForEach(_ => { terIds += _.resource_id.ToString() + ","; });
                }
                if (!string.IsNullOrEmpty(terIds))
                {
                    terIds = terIds.Substring(0, terIds.Length - 1);
                }
                #region 摘要查询数量
                todayTodoCount      = caDal.GetTodoCountByRes((long)resourceId, $" and start_date <={Tools.Date.DateHelper.ToUniversalTimeStamp(end)} and start_date>={Tools.Date.DateHelper.ToUniversalTimeStamp(start)}");
                overdueTodoCount    = caDal.GetTodoCountByRes((long)resourceId, $" and status_id = {(int)DTO.DicEnum.ACTIVITY_STATUS.NOT_COMPLETED} and end_date<={timeNow}");
                myAsignToOtherCount = caDal.GetTodoCountByRes(0, resourceId == 0?$" and create_user_id <> resource_id" :$" and create_user_id= {resourceId} and resource_id<>{resourceId}");

                needEditOppoCount = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id where  cp.delete_time = 0 and projected_close_date < '{DateTime.Now.ToString("yyyy-MM-dd")}' and cp.status_id ={(int)DicEnum.OPPORTUNITY_STATUS.ACTIVE} " + accountLimitSql + oppoLimitSql + (resourceId == 0?"":$" and cp.resource_id = {(long)resourceId}")));

                yesTicketCount = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) FROM sdk_task st INNER JOIN crm_account ca on st.account_id = ca.id where st.type_id in (1809,1818)  and st.create_time <={Tools.Date.DateHelper.ToUniversalTimeStamp(yesEnd)} and st.create_time>={Tools.Date.DateHelper.ToUniversalTimeStamp(yesStart)}" + (resourceId == 0 ? "" : $" and ca.resource_id = {(long)resourceId}")));

                todayTicketCount = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) FROM sdk_task st INNER JOIN crm_account ca on st.account_id = ca.id where st.type_id in (1809,1818)  and st.create_time <={Tools.Date.DateHelper.ToUniversalTimeStamp(end)} and st.create_time>={Tools.Date.DateHelper.ToUniversalTimeStamp(start)}" + (resourceId == 0 ? "" : $" and ca.resource_id = {(long)resourceId}")));

                //
                monthLostOppo = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity where delete_time = 0 and actual_closed_time <= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} and actual_closed_time >= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.LOST}" + (resourceId == 0 ? "" : $" and resource_id = {(long)resourceId}")));

                monthClosedOppo = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity where delete_time = 0 and actual_closed_time <= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} and actual_closed_time >= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.CLOSED}" + (resourceId == 0 ? "" : $" and resource_id = {(long)resourceId}")));

                monthCloseOppo = Convert.ToInt32(caDal.GetSingle($"SELECT count(1) from crm_opportunity where delete_time = 0 and projected_close_date <= {monthEnd.ToString("yyyy-MM-dd")} and projected_close_date >= {monthStart.ToString("yyyy-MM-dd")} and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.ACTIVE}" + (resourceId == 0 ? "" : $" and resource_id = {(long)resourceId}")));

                monthClosedOppoList = caDal.FindListBySql <crm_opportunity>($"SELECT * from crm_opportunity where delete_time = 0 and actual_closed_time <= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} and actual_closed_time >= {Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and status_id ={(int)DicEnum.OPPORTUNITY_STATUS.CLOSED}" + (resourceId == 0 ? "" : $" and resource_id = {(long)resourceId}"));
                #endregion

                accountCount      = Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account ca where delete_time = 0 " + accountLimitSql + (resourceId != 0? "  and resource_id =" + resourceId.ToString() : "")));
                activeOppoList    = caDal.FindListBySql <crm_opportunity>($"SELECT * from crm_opportunity cp inner join crm_account ca on cp.account_id = ca.id where cp.delete_time = 0 and cp.status_id = {(int)DicEnum.OPPORTUNITY_STATUS.ACTIVE} " + accountLimitSql + " " + oppoLimitSql + (resourceId != 0 ? "  and cp.resource_id =" + resourceId.ToString() : ""));
                newOppoMonthCount = Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_opportunity where delete_time = 0 and create_time>={Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and create_time<={Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} " + (resourceId != 0 ? "  and resource_id =" + resourceId.ToString() : "")));

                updateOppoNoteCount = Convert.ToInt32(caDal.GetSingle($"SELECT * from com_activity ca INNER JOIN crm_opportunity co on ca.opportunity_id = co.id where ca.action_type_id = {(int)DicEnum.ACTIVITY_TYPE.OPPORTUNITYUPDATE} and ca.cate_id = {(int)DicEnum.ACTIVITY_CATE.NOTE} and ca.delete_time = 0 and co.delete_time = 0 and ca.create_time>{Tools.Date.DateHelper.ToUniversalTimeStamp(monthStart)} and ca.create_time<={Tools.Date.DateHelper.ToUniversalTimeStamp(monthEnd)} " + (resourceId != 0 ? "  and co.resource_id =" + resourceId.ToString() : "")));
                if (resourceId == 0)
                {
                    // 全部员工时获取所有的区域信息
                    if (terrList != null && terrList.Count > 0)
                    {
                        terrList.ForEach(_ => {
                            terrAccDic.Add(_.id, Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account where delete_time = 0 and territory_id =" + _.id.ToString())));
                        });
                    }
                }
                else
                {
                    accClassWhere = accountLimitSql + $" and resource_id ={resourceId.ToString()}";
                    // 单个员工时,获取单个员工下的所有区域信息
                    if (terList != null && terList.Count > 0)
                    {
                        terList.ForEach(_ => {
                            terrAccDic.Add(_.territory_id, Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account where delete_time = 0 and territory_id =" + _.id.ToString())));
                        });
                    }
                }
                resQuotaList = new DAL.sys_resource_sales_quota_dal().GetQuotaByResIds(resourceId.ToString(), DateTime.Now.Year, DateTime.Now.Month);
            }
            if (monthClosedOppoList != null && monthClosedOppoList.Count > 0)
            {
                monthClosedOppo = monthClosedOppoList.Count;
                monthClosedOppoList.ForEach(_ => {
                    prodessAmount  += _.ext1;
                    trainsAmount   += _.ext2;
                    hardwareAmount += _.ext3;
                    monthFeeAmount += _.ext4;
                    otherAmount    += _.ext5;
                    monthAmount    += oppBLl.ReturnOppoRevenue(_.id);
                });
            }
            if (activeOppoList != null && activeOppoList.Count > 0)
            {
                activeOppoCount = activeOppoList.Count;
            }

            if (accClassList != null && accClassList.Count > 0)
            {
                accClassList.ForEach(_ => {
                    classAccDic.Add(_.id, Convert.ToInt32(caDal.GetSingle($"SELECT COUNT(1) from crm_account ca where delete_time = 0 and classification_id =" + _.id.ToString() + " " + accClassWhere)));
                })
                ;
            }

            if (resQuotaList != null && resQuotaList.Count > 0)
            {
                quotaAmount   = resQuotaList.Sum(_ => _.amount ?? 0);
                quotaProdess  = resQuotaList.Sum(_ => _.opportunity_ext1 ?? 0);
                quotaTrains   = resQuotaList.Sum(_ => _.opportunity_ext2 ?? 0);
                quotaHardware = resQuotaList.Sum(_ => _.opportunity_ext3 ?? 0);
                quotaMonthFee = resQuotaList.Sum(_ => _.opportunity_ext4 ?? 0);
                quotaOther    = resQuotaList.Sum(_ => _.opportunity_ext5 ?? 0);
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisBookMark  = new IndexBLL().GetSingBook(Request.Url.LocalPath, LoginUserId);
            refreshMin    = Request.QueryString["refreshMin"];
            allTicketList = ticBll.GetAllTicket();
            countDic      = ticBll.GetServiceDeskCount();
            if (allTicketList != null && allTicketList.Count > 0)
            {
                classTickDic = allTicketList.GroupBy(_ =>
                {
                    long classId = 0; var acc = comBll.GetCompany(_.account_id);
                    if (acc != null)
                    {
                        classId = acc.classification_id ?? 0;
                    }
                    return(classId);
                }).OrderBy(_ => _.Key).ToDictionary(_ => _.Key, _ => _.ToList());
                productTickDic = allTicketList.GroupBy(_ =>
                {
                    long productId = 0;
                    if (_.installed_product_id != null)
                    {
                        var insPro = insProBll.GetById((long)_.installed_product_id);
                        if (insPro != null)
                        {
                            productId = insPro.product_id;
                        }
                    }
                    return(productId);
                }).OrderBy(_ => _.Key).ToDictionary(_ => _.Key, _ => _.ToList());
            }
            // {"row":8,"t1":"t","col1":"71,72","col2":"71,72,73"}
            var ticketLimtJson = "{\"row\":\"8\",\"t1\":\"t\",\"col1\":\"71,72\",\"col2\":\"71,72,73\"}";
            var ticketLimitSql = Convert.ToString(new DAL.sdk_task_dal().GetSingle($"select f_rpt_getsql_limit('{ticketLimtJson}',{LoginUserId.ToString()})"));
            var limitTicket    = new DAL.v_ticket_dal().FindListBySql("SELECT * from v_ticket t where t.type_id = 1809 " + ticketLimitSql);
            var resIdList      = ticBll.ReturnResIdsByTicket(limitTicket);

            if (resIdList != null && resIdList.Count > 0 && resList != null && resList.Count > 0)
            {
                limitResList = new List <sys_resource>();
                resIdList.ForEach(_ =>
                {
                    var thisRes = resList.FirstOrDefault(r => r.id.ToString() == _);
                    if (thisRes != null)
                    {
                        limitResList.Add(thisRes);
                    }
                });
            }
        }