示例#1
0
        protected SdkWorkEntryDto GetParam()
        {
            SdkWorkEntryDto para      = new SdkWorkEntryDto();
            var             pageEntry = AssembleModel <sdk_work_entry>();
            //var pageRecord = AssembleModel<sdk_work_record>();
            //var startTime = Request.Form["startTime"];
            //var endTime = Request.Form["endTime"];
            //var date = Request.Form["tmeDate"];
            //if(!string.IsNullOrEmpty(startTime)&& !string.IsNullOrEmpty(endTime) && !string.IsNullOrEmpty(date))
            //{
            //    var starString = date + " " + startTime;
            //    var endString = date + " " + endTime;
            //    var startDate = DateTime.Parse(starString);
            //    var endDate = DateTime.Parse(endString);
            //    if (endDate < startDate)
            //    {
            //        endDate = endDate.AddDays(1);
            //    }
            //    var startLong = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate);
            //    var endLong = Tools.Date.DateHelper.ToUniversalTimeStamp(endDate);
            //    pageEntry.start_time = startLong;
            //    pageEntry.end_time = endLong;
            //    //pageRecord.start_time = startLong;
            //    //pageRecord.end_time = endLong;
            //}
            var PageEntryIds = Request.Form["PageEntryIds"];

            if (!string.IsNullOrEmpty(PageEntryIds))
            {
                var entArr = PageEntryIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List <PageEntryDto> entDtoList = new List <PageEntryDto>();
                //var hours_worked = Request.Form["hours_worked"];
                foreach (var thisEntArrId in entArr)
                {
                    var thisSum    = Request.Form["summ_" + thisEntArrId];
                    var thisIne    = Request.Form["inter_" + thisEntArrId];
                    var thisDate   = Request.Form["entry_date_" + thisEntArrId];
                    var thisHour   = Request.Form["entry_work_hour_" + thisEntArrId];
                    var thisHoured = Request.Form["entry_worked_" + thisEntArrId];
                    if (string.IsNullOrEmpty(thisDate))
                    {
                        continue;
                    }
                    #region 开始结束时间
                    var startTime = Request.Form["entry_start_date_" + thisEntArrId];
                    var endTime   = Request.Form["entry_end_date_" + thisEntArrId];

                    long?startLongDate = null;
                    long?endLongDate   = null;
                    if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
                    {
                        var starString = thisDate + " " + startTime;
                        var endString  = thisDate + " " + endTime;
                        var startDate  = DateTime.Parse(starString);
                        var endDate    = DateTime.Parse(endString);
                        if (endDate < startDate)
                        {
                            endDate = endDate.AddDays(1);
                        }
                        startLongDate = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate);
                        endLongDate   = Tools.Date.DateHelper.ToUniversalTimeStamp(endDate);
                    }
                    #endregion

                    var thisOffSet = Request.Form["entry_offset_" + thisEntArrId];
                    var thisBill   = Request.Form["entry_billed_" + thisEntArrId];

                    decimal?bill = null;
                    if (!string.IsNullOrEmpty(thisBill))
                    {
                        bill = decimal.Parse(thisBill);
                    }

                    if ((!string.IsNullOrEmpty(thisHour) || !string.IsNullOrEmpty(thisHoured)) && !string.IsNullOrEmpty(thisDate))
                    {
                        entDtoList.Add(new PageEntryDto()
                        {
                            id        = long.Parse(thisEntArrId),
                            sumNote   = thisSum,
                            ineNote   = thisIne,
                            time      = DateTime.Parse(thisDate),
                            startDate = startLongDate,
                            endDate   = endLongDate,
                            workHours = !string.IsNullOrEmpty(thisHour)? decimal.Parse(thisHour): decimal.Parse(thisHoured),
                            offset    = !string.IsNullOrEmpty(thisOffSet)?decimal.Parse(thisOffSet) :0,
                            billHours = bill,
                        });
                    }
                }
                para.pagEntDtoList = entDtoList;
            }

            if (pageEntry.contract_id != null && pageEntry.service_id != null)
            {
                var thisConSer = new ctt_contract_service_dal().GetServiceByConSerId((long)pageEntry.contract_id, (long)pageEntry.service_id);
                if (thisConSer != null)
                {
                    pageEntry.service_id = thisConSer.id;
                }
                else
                {
                    pageEntry.service_id = null;
                }
            }
            else
            {
                pageEntry.service_id = null;
            }

            var pageProject = new pro_project_dal().FindNoDeleteById(long.Parse(Request.Form["project_id"]));
            if (pageProject != null)
            {
                //if (pageProject.type_id == (int)DicEnum.PROJECT_TYPE.IN_PROJECT)
                //{
                //    //pageRecord.entry_type_id = (int)DicEnum.WORK_ENTRY_TYPE.COMPAMY_IN_ENTRY;
                //}
                //else
                //{
                //    pageRecord.entry_type_id = (int)DicEnum.WORK_ENTRY_TYPE.PROJECT_ENTRY;
                //}
            }
            pageEntry.show_on_invoice = (sbyte)(ShowOnInv.Checked ? 1 : 0);
            pageEntry.is_billable     = (sbyte)(isBilled.Checked?0:1);
            if (!isAdd)
            {
                thisWorkEntry.contract_id     = pageEntry.contract_id;
                thisWorkEntry.task_id         = pageEntry.task_id;
                thisWorkEntry.service_id      = pageEntry.service_id;
                thisWorkEntry.resource_id     = pageEntry.resource_id;
                thisWorkEntry.role_id         = pageEntry.role_id;
                thisWorkEntry.cost_code_id    = pageEntry.cost_code_id;
                thisWorkEntry.start_time      = pageEntry.start_time;
                thisWorkEntry.end_time        = pageEntry.end_time;
                thisWorkEntry.hours_worked    = pageEntry.hours_worked;
                thisWorkEntry.hours_billed    = pageEntry.hours_billed;
                thisWorkEntry.offset_hours    = pageEntry.offset_hours;
                thisWorkEntry.internal_notes  = pageEntry.internal_notes;
                thisWorkEntry.summary_notes   = pageEntry.summary_notes;
                thisWorkEntry.is_billable     = pageEntry.is_billable;
                thisWorkEntry.show_on_invoice = pageEntry.show_on_invoice;
                para.workEntry = thisWorkEntry;
                //if (thisWorkEntry != null)
                //{
                //    var thisWorkRecord = new sdk_work_record_dal().FindNoDeleteById((long)thisWorkEntry.work_record_id);
                //    if (thisWorkRecord != null)
                //    {
                //        //thisWorkRecord.contract_id = pageRecord.contract_id;
                //        //thisWorkRecord.task_id = pageRecord.task_id;
                //        //thisWorkRecord.resource_id = pageRecord.resource_id;
                //        //thisWorkRecord.entry_type_id = pageRecord.entry_type_id;
                //        //thisWorkRecord.role_id = pageRecord.role_id;
                //        //thisWorkRecord.cost_code_id = pageRecord.cost_code_id;
                //        //thisWorkRecord.start_time = pageRecord.start_time;
                //        //thisWorkRecord.end_time = pageRecord.end_time;
                //        //para.wordRecord = thisWorkRecord;
                //    }
                //}
            }
            else
            {
                para.workEntry = pageEntry;
                // para.wordRecord = pageRecord;
            }


            var remain_hours = Request.Form["remain_hours"];
            if (!string.IsNullOrEmpty(remain_hours))
            {
                para.remain_hours = decimal.Parse(remain_hours);
            }
            var status_id = Request.Form["status_id"];
            if (!string.IsNullOrEmpty(status_id))
            {
                para.status_id = int.Parse(status_id);
            }

            #region 通知相关
            var notify_id = Request.Form["notify_id"];
            if (!string.IsNullOrEmpty(notify_id))
            {
                para.notify_id      = int.Parse(notify_id);
                para.contact_ids    = Request.Form["contact_ids"];
                para.resIds         = Request.Form["resIds"];
                para.otherEmail     = Request.Form["otherEmail"];
                para.subjects       = Request.Form["subjects"];
                para.AdditionalText = Request.Form["AdditionalText"];
            }
            #endregion


            return(para);
        }
示例#2
0
        /// <summary>
        /// 获取相关参数
        /// </summary>s
        protected SdkWorkEntryDto GetParam()
        {
            SdkWorkEntryDto param     = new SdkWorkEntryDto();
            var             pageEntry = AssembleModel <sdk_work_entry>();

            // 除了工时信息外,获取相关附加信息,成本信息,邮件信息

            if (!string.IsNullOrEmpty(Request.Form["ckIsBilled"]))
            {
                pageEntry.is_billable = 1;
            }
            else
            {
                pageEntry.is_billable = 0;
            }
            if (!string.IsNullOrEmpty(Request.Form["ckShowOnInv"]))
            {
                pageEntry.show_on_invoice = 1;
            }
            else
            {
                pageEntry.show_on_invoice = 0;
            }
            var status_id = Request.Form["status_id"];

            if (!string.IsNullOrEmpty(status_id))
            {
                param.status_id = int.Parse(status_id);
            }
            var labourDate = Request.Form["LabourDate"];
            var startTime  = Request.Form["startTime"];
            var endTime    = Request.Form["endTime"];

            if (!string.IsNullOrEmpty(labourDate) && !string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
            {
                var startDate = DateTime.Parse(labourDate + " " + startTime);
                var endDate   = DateTime.Parse(labourDate + " " + endTime);
                pageEntry.start_time = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate);
                pageEntry.end_time   = Tools.Date.DateHelper.ToUniversalTimeStamp(endDate);
            }
            pageEntry.hours_billed = (pageEntry.hours_worked ?? 0) + pageEntry.offset_hours;
            if (!string.IsNullOrEmpty(Request.Form["ckAppThisResou"]))
            {
                param.isAppthisResoule = true;
            }
            if (!string.IsNullOrEmpty(Request.Form["ckAppOtherResou"]))
            {
                param.isAppOtherResoule = true;
            }
            if (!string.IsNullOrEmpty(Request.Form["CkNoteCreat"]))
            {
                param.isAppOtherNote = true;
            }
            if (!string.IsNullOrEmpty(Request.Form["ckBillToAccount"]))
            {
                param.billToAccount = true;
            }
            param.ticketId = thisTicket.id;
            var charge_cost_code_id = Request.Form["charge_cost_code_id"];
            var quantity            = Request.Form["quantity"];

            if (!string.IsNullOrEmpty(charge_cost_code_id) && !string.IsNullOrEmpty(quantity))
            {
                var charge = new ctt_contract_cost()
                {
                    cost_code_id = long.Parse(charge_cost_code_id),
                    description  = Request.Form["description"],
                    quantity     = decimal.Parse(quantity),
                };
                var unit_price = Request.Form["unit_price"];
                if (!string.IsNullOrEmpty(unit_price))
                {
                    charge.unit_price = decimal.Parse(unit_price);
                }
                param.thisCost = charge;
            }
            pageEntry.task_id = thisTicket.id;
            if (isAdd)
            {
                var parentType  = Request.QueryString["AddType"];
                var parentobjId = Request.QueryString["parentObjId"];
                if (!string.IsNullOrEmpty(parentType) && !string.IsNullOrEmpty(parentobjId))
                {
                    if (parentType == "att")
                    {
                        pageEntry.parent_attachment_id = int.Parse(parentobjId);
                    }
                    else if (parentType == "note")
                    {
                        pageEntry.parent_note_id = int.Parse(parentobjId);
                    }
                    else if (parentType == "entry")
                    {
                        pageEntry.parent_id = int.Parse(parentobjId);
                    }
                }
                if (!string.IsNullOrEmpty(Request.Form["resource_id"]))
                {
                    pageEntry.resource_id = LoginUserId;
                }
                else
                {
                    pageEntry.resource_id = long.Parse(Request.Form["resource_id"]);
                }
                param.workEntry = pageEntry;
            }
            else
            {
                if (isAllowAgentRes)
                {
                    //ticketLabour.resource_id = pageEntry.resource_id;
                    ticketLabour.contract_id = pageEntry.contract_id;
                }
                ticketLabour.service_id      = pageEntry.service_id;
                ticketLabour.cost_code_id    = pageEntry.cost_code_id;
                ticketLabour.is_billable     = pageEntry.is_billable;
                ticketLabour.show_on_invoice = pageEntry.show_on_invoice;
                ticketLabour.role_id         = pageEntry.role_id;
                ticketLabour.start_time      = pageEntry.start_time;
                ticketLabour.end_time        = pageEntry.end_time;
                ticketLabour.hours_worked    = pageEntry.hours_worked;
                ticketLabour.offset_hours    = pageEntry.offset_hours;
                ticketLabour.hours_billed    = pageEntry.hours_billed;
                ticketLabour.summary_notes   = pageEntry.summary_notes;
                ticketLabour.internal_notes  = pageEntry.internal_notes;

                param.workEntry = ticketLabour;
            }


            return(param);
        }