Пример #1
0
 public static bool StartPlan(long id)
 {
     try
     {
         foreach (EPlan p in EPlanDictionary.GetInstance().GetList())
         {
             if (p.state == true)
             {
                 p.state  = false;
                 p.stopF += 1;
                 p.lastT += DateTime.Now - p.startT.Last();//*** have problem here ***
             }
         }
         EPlan plan = EPlanDictionary.GetInstance().find(id);
         plan.state   = true;
         plan.startF += 1;
         plan.startT.Add(DateTime.Now);
         return(true);
     }
     catch (Exception ex)
     {
         Logger.WriteLogs("MainFormController/StartPlan Error: " + ex.Message);
         return(false);
     }
 }
Пример #2
0
        public MyResult Create(string par0, string par1)
        {
            Assembly asmb   = Assembly.GetAssembly(typeof(ServiceReturn));
            Type     type   = asmb.GetType(par0);
            object   obj    = JsonConvert.DeserializeObject(par1, type);
            object   newObj = DBBase.Create(obj);

            if (type == typeof(ETask))
            {
                ETask task = (ETask)obj;
                if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0)
                {
                    EUser         myuser     = DBBase.Get <EUser>(MySession.UserID);
                    EUser         excuteuser = DBBase.Get <EUser>(task.ExecutorID);
                    List <string> ulist      = new List <string>();
                    ulist.Add(excuteuser.PushClientID);
                    PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true);
                }
            }
            else if (type == typeof(EPlan))
            {
                EPlan       plan       = (EPlan)obj;
                EProject    project    = DBBase.Get <EProject>(plan.ProjectID);
                EUserSearch userSearch = new EUserSearch()
                {
                    IsDefault = false, Name = project.Name + "-" + plan.Name, UserID = MySession.UserID, ProjectID = plan.ProjectID, PlanID = plan.ID
                };
                DBBase.Create(userSearch);
            }
            return(ServiceResult(newObj));
        }
Пример #3
0
        public IHttpActionResult getplanes([FromBody] getdata data)
        {
            try
            {
                MultigymEntities1 context = new MultigymEntities1();
                List <MG_Planes>  plans   = new List <MG_Planes>();
                plans = (from x in context.MG_Planes
                         where x.Activo == true
                         select x).ToList();

                List <EPlan> lista = new List <EPlan>();
                foreach (var p in plans)
                {
                    var pl = new EPlan();
                    pl.idplan      = p.Id;
                    pl.plan        = p.Nombre;
                    pl.descripcion = p.Descripcion;
                    pl.precio      = p.Creditos;
                    pl.creditos    = p.Creditos;
                    pl.activo      = p.Activo;
                    lista.Add(pl);
                }
                return(Ok(RespuestaApi <List <EPlan> > .createRespuestaSuccess(lista)));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.Message)));
            }
        }
Пример #4
0
        public static bool AddPlan(string p, long id)
        {
            try
            {
                if (TaskDictionary.GetInstance().find(0) == null)
                {
                    Model.Elements.Task task = new Model.Elements.Task();
                    task.name  = "DEFAULT";
                    task.id    = 0;
                    task.scale = 31;
                    TaskDictionary.GetInstance().Add(task);

                    STask st = new STask();
                    st.name  = "DEFAULT_STASK";
                    st.id    = 0;
                    st.order = 0;
                    STaskDictionary.GetInstance().Add(st);

                    SubTask subt = new SubTask();
                    subt.name  = p;
                    subt.id    = id;
                    subt.showT = DateTime.Now;
                    SubTaskDictionary.GetInstance().Add(subt);

                    EPlan plan = new EPlan();
                    plan.name  = p;
                    plan.id    = id;
                    plan.showT = DateTime.Now;
                    EPlanDictionary.GetInstance().Add(plan);

                    st.subtaskID.Add(subt.id);
                    task.staskID.Add(st.id);
                }
                else
                {
                    Model.Elements.Task task = TaskDictionary.GetInstance().find(0);

                    SubTask subt = new SubTask();
                    subt.name  = p;
                    subt.id    = id;
                    subt.showT = DateTime.Now;
                    SubTaskDictionary.GetInstance().Add(subt);

                    EPlan plan = new EPlan();
                    plan.name  = p;
                    plan.id    = id;
                    plan.showT = DateTime.Now;
                    EPlanDictionary.GetInstance().Add(plan);

                    STaskDictionary.GetInstance().find(0).subtaskID.Add(subt.id);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.WriteLogs("MainFormController/AddPlan Error: " + ex.Message);
                return(false);
            }
        }
Пример #5
0
        //---------------------------------------------------------------
        // Metodos públicos de la clase
        //---------------------------------------------------------------

        #region Metodos publicos de la clase
        #endregion

        //---------------------------------------------------------------
        // Metodos privados de la clase
        //---------------------------------------------------------------

        #region Metodos del Generador
        /// <summary>
        /// Agrega o modifica un registro de la tabla: Planes
        /// (Código Fijo)
        /// </summary>
        /// <param name="p_dbcAccess">Conexion a la base de datos</param>
        /// <param name="p_entPlan">Entidad con los datos a procesar</param>
        /// <param name="p_smResult">Estado final de la operacion</param>
        internal static void Save_f(DBConn p_dbcAccess,
                                    ref EPlan p_entPlan,
                                    StatMsg p_smResult)
        {
            // *********
            // Agregar acá los procesos adicionales
            // *********
        }
Пример #6
0
 /// <summary>
 /// Agrega validacion de integridad a una entidad: Plan
 /// (Código Fijo)
 /// </summary>
 /// <param name="p_dbcAccess">Conexion a la base de datos</param>
 /// <param name="p_entPlan">Entidad con los datos a validar</param>
 /// <param name="p_smResult">Estado final de la operacion</param>
 internal static void TInt_f(DBConn p_dbcAccess,
                             EPlan p_entPlan,
                             StatMsg p_smResult)
 {
     // *********
     // Agregar acá las validaciones adicionales
     // *********
 }
Пример #7
0
        public MyResult GetPlan(int par0)
        {
            EPlan    plan    = DBBase.Query <EPlan>("ProjectID=" + par0).FirstOrDefault();
            MyResult ret     = ServiceResult(plan);
            EProject project = DBBase.Get <EProject>(par0);

            ret.ServiceReturn.AddData("ProjectName", project.Name);
            return(ret);
        }
Пример #8
0
 protected override void Init()
 {
     base.Init();
     PageTitle.Init("计划详情", App.Instance.Theme.TitleBgColor, App.Instance.Theme.TitleFontColor, BtnBack);
     PageTitle.AddButton("", App.Instance.ImageManger.ImageList[5], OnSavePlan);
     BaseOperation_Service.Get <EPlan>(this.GetPar <int>(0), t =>
     {
         ThePlan = t.GetData() as EPlan;
         BindData();
     });
 }
Пример #9
0
 protected override void Init()
 {
     base.Init();
     BaseOperation_Service.Get <EPlan>(GetPar <int>(0), t =>
     {
         EPlan = t.GetData() as EPlan;
         PageTitle.Init("完成情况-" + EPlan.Name, App.Instance.Theme.TitleBgColor, App.Instance.Theme.TitleFontColor, BtnBack);
         selectPeopleID = -1;
         BindPeopleSelect();
         BindTaskListView();
     });
 }
Пример #10
0
 public void Remove(EPlan p)
 {
     if (planDictionary.ContainsKey(p.id))
     {
         lock (_lock)
         {
             if (planDictionary.ContainsKey(p.id))
             {
                 planDictionary.Remove(p.id);
             }
         }
     }
 }
Пример #11
0
 public void Add(EPlan p)
 {
     if (!planDictionary.ContainsKey(p.id))
     {
         lock (_lock)
         {
             if (!planDictionary.ContainsKey(p.id))
             {
                 planDictionary.Add(p.id, p);
             }
         }
     }
 }
Пример #12
0
 protected override void Init()
 {
     base.Init();
     BaseOperation_Service.Get <EPlan>(GetPar <int>(0), t =>
     {
         EPlan = t.GetData() as EPlan;
         PageTitle.Init(EPlan.Name, App.Instance.Theme.TitleBgColor, App.Instance.Theme.TitleFontColor, BtnBack);
         PageTitle.AddButton("", App.Instance.ImageManger.ImageList[1], AddTask);
         PageTitle.AddButton("", App.Instance.ImageManger.ImageList[2], DeletePlan);
         PageTitle.AddButton("", App.Instance.ImageManger.ImageList[10], GoToChart);
         PageTitle.AddButton("", App.Instance.ImageManger.ImageList[8], GoToSet);
         Tab.Init(OnTabClicked, App.Instance.Theme.SelectedItemBgColor);
         selectPeopleID = -1;
         BindPeopleSelect();
         BindTaskListView();
     });
 }
Пример #13
0
    void AddPlan(GameObject g)
    {
        App.Instance.DialogBox.Show("添加计划", "Page_AddPlan", "", 350, 200, btn =>
        {
            EPlan p     = new EPlan();
            p.Name      = App.Instance.DialogBox.Content.GetComponentInChildren <InputField>().text;
            p.ProjectID = EProject.ID;
            p.BeginTime = System.DateTime.Now;
            p.EndTime   = System.DateTime.Now;

            BaseOperation_Service.Create <EPlan>(p, t =>
            {
                BindData();
                App.Instance.DialogBox.Hide();
                App.Instance.HintBox.Show("操作成功!");
            });
        }, null);
    }
Пример #14
0
 public bool Upgrade(EPlan oldp, EPlan newp)
 {
     try
     {
         lock (_lock)
         {
             if (planDictionary.ContainsKey(oldp.id))
             {
                 planDictionary.Remove(oldp.id);
             }
             planDictionary.Add(newp.id, newp);
             return(true);
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message);
         return(false);
     }
 }
Пример #15
0
 public static bool DonePlan(long id)
 {
     try
     {
         EPlan plan = EPlanDictionary.GetInstance().find(id);
         if (plan.state)
         {
             plan.endT      = DateTime.Now;
             plan.lastT    += DateTime.Now - plan.startT.Last();
             plan.endState  = true;
             plan.progress += 10;
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.WriteLogs("MainFormController/DonePlan Error: " + ex.Message);
         return(false);
     }
 }
Пример #16
0
        private void InitUser(EUser user)
        {
            EProject defaultProject = new EProject()
            {
                Name = "默认项目", CreateTime = DateTime.Now, CreaterID = user.ID
            };

            defaultProject = ProjectController.CreateProject(defaultProject, user.ID);

            EPlan defaultPlan = new EPlan()
            {
                ProjectID = defaultProject.ID, Name = "默认计划", BeginTime = DateTime.Now, EndTime = DateTime.Now
            };

            defaultPlan = (EPlan)DBBase.Create(defaultPlan);
            EUserSearch userSearch = new EUserSearch()
            {
                IsDefault = true, Name = "默认项目计划", UserID = user.ID, ProjectID = defaultPlan.ProjectID, PlanID = defaultPlan.ID
            };

            DBBase.Create(userSearch);
        }
Пример #17
0
        private static void LoadTodoList()
        {
            try
            {
                PopularityCal.Calculator();
            }
            catch (Exception ex)
            {
                Logger.WriteLogs("Load PopularityCal Error: " + ex.Message);
            }

            try
            {
                float totalWorkHour                 = 0;
                Dictionary <long, int> popDic       = new Dictionary <long, int>();
                Dictionary <long, int> sortedPopDic = new Dictionary <long, int>();
                foreach (Model.Elements.Task t in TaskDictionary.GetInstance().GetList())
                {
                    if (!t.state)
                    {
                        popDic.Add(t.id, t.popularity);
                    }
                }
                sortedPopDic = popDic.OrderBy(o => o.Value).ToDictionary(o => o.Key, p => p.Value);
                foreach (KeyValuePair <long, int> kvp in sortedPopDic)
                {
                    if (kvp.Value == 0)
                    {
                        Dictionary <int, long> staskDic = new Dictionary <int, long>();
                        foreach (long l in TaskDictionary.GetInstance().find(kvp.Key).staskID)
                        {
                            if (!STaskDictionary.GetInstance().find(l).state)
                            {
                                staskDic.Add(STaskDictionary.GetInstance().find(l).order, l);
                            }
                        }
                        Dictionary <int, long> sortedStaskDic = staskDic.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

                        Dictionary <int, long> subtaskDic = new Dictionary <int, long>();
                        foreach (long l in STaskDictionary.GetInstance().find(sortedStaskDic.First().Value).subtaskID)
                        {
                            if (!SubTaskDictionary.GetInstance().find(l).state)
                            {
                                subtaskDic.Add(SubTaskDictionary.GetInstance().find(l).order, l);
                            }
                        }
                        Dictionary <int, long> sortedSubtaskDic = subtaskDic.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

                        SubTaskDictionary.GetInstance().find(sortedSubtaskDic.First().Value).ready = true;
                        if (SubTaskDictionary.GetInstance().find(sortedSubtaskDic.First().Value).expecLastT == null)
                        {
                            totalWorkHour += 1;
                        }
                        else
                        {
                            totalWorkHour += SubTaskDictionary.GetInstance().find(sortedSubtaskDic.First().Value).expecLastT.Hours;
                        }
                    }
                }
                Dictionary <long, int> revSortedPopDic = sortedPopDic.Reverse().ToDictionary(o => o.Key, p => p.Value);
                int maxNum = 0;
                while (totalWorkHour < 16)
                {
                    int forN = 0;
                    foreach (KeyValuePair <long, int> kvp in revSortedPopDic)
                    {
                        if (kvp.Value != 0)
                        {
                            Dictionary <int, long> staskDic = new Dictionary <int, long>();
                            foreach (long l in TaskDictionary.GetInstance().find(kvp.Key).staskID)
                            {
                                if (!STaskDictionary.GetInstance().find(l).state)
                                {
                                    staskDic.Add(STaskDictionary.GetInstance().find(l).order, l);
                                }
                            }
                            Dictionary <int, long> sortedStaskDic = staskDic.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

                            Dictionary <int, long> subtaskDic = new Dictionary <int, long>();
                            foreach (long l in STaskDictionary.GetInstance().find(sortedStaskDic.First().Value).subtaskID)
                            {
                                if (!SubTaskDictionary.GetInstance().find(l).state &&
                                    !SubTaskDictionary.GetInstance().find(l).ready)
                                {
                                    subtaskDic.Add(SubTaskDictionary.GetInstance().find(l).order, l);
                                }
                            }
                            Dictionary <int, long> sortedSubtaskDic = subtaskDic.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

                            SubTaskDictionary.GetInstance().find(sortedSubtaskDic.First().Value).ready = true;
                            if (SubTaskDictionary.GetInstance().find(sortedSubtaskDic.First().Value).expecLastT == null)
                            {
                                totalWorkHour += 1;
                            }
                            else
                            {
                                totalWorkHour += SubTaskDictionary.GetInstance().find(sortedSubtaskDic.First().Value).expecLastT.Hours;
                            }
                        }
                        forN += 1;
                        if (forN > maxNum)
                        {
                            break;
                        }
                    }
                    maxNum += 1;
                    if (maxNum > 24)
                    {
                        break;
                    }
                }
                foreach (SubTask st in SubTaskDictionary.GetInstance().GetList())
                {
                    EPlan ep = new EPlan();
                    ep.name   = st.name;
                    ep.id     = st.id;
                    ep.finalT = st.finalT;
                    ep.lastT  = st.lastT;
                    ep.showT  = st.showT;
                    ep.startF = st.startF;
                    ep.stopF  = st.stopF;
                    ep.startT = st.startT;
                    ep.stopT  = st.stopT;
                    EPlanDictionary.GetInstance().Add(ep);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLogs("Load TodoList Error: " + ex.Message);
            }
        }