private void BookBtn_Click(object sender, EventArgs e)
        {
            using (var db = new Session2Entities())
            {
                Booking booking = new Booking();
                booking.userIdFK = users.userId;
                if (dataGridView1.SelectedRows.Count == 1)
                {
                    foreach (DataGridViewRow dr in dataGridView1.SelectedRows)
                    {
                        var ID = int.Parse(dr.Cells["ID"].Value.ToString());
                        booking.packageIdFK = ID;
                        var quan = int.Parse(dr.Cells["Availabile Qty"].Value.ToString());
                        if (quan >= DQ.Value)
                        {
                            booking.quantityBooked = (int)DQ.Value;
                        }
                        else
                        {
                            MessageBox.Show("Invalid Amount!");
                            return;
                        }
                        booking.status = "Pending";
                        db.Bookings.Add(booking);
                        try
                        {
                            db.SaveChanges();

                            //Will hendle this when the manager approves the booking
                            //var q2 = db.Packages.Where(x => x.packageId == ID).FirstOrDefault();
                            //q2.packageQuantity -= (int)DQ.Value;
                            db.SaveChanges();
                            MessageBox.Show("Success!");
                            var q = db.Packages.ToList();
                            dataGridView1.DataSource            = CDT(q);
                            dataGridView1.SelectionMode         = DataGridViewSelectionMode.FullRowSelect;
                            dataGridView1.Columns["ID"].Visible = false;
                        }
                        catch (Exception ES)
                        {
                            MessageBox.Show(ES.ToString());
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Pick Only 1!");
                    return;
                }
            }
        }
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            using (var db = new Session1Entities())
            {
                var query = db.Resources.Where(x => x.resId == IDs).FirstOrDefault();
                query.remainingQuantity = (int)quantity.Value;

                if (skills.Visible == false)
                {
                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Successful!");
                        this.Hide();
                        ResouceManagement resouceManagement = new ResouceManagement();
                        resouceManagement.Show();
                    }
                    catch (Exception ES)
                    {
                        MessageBox.Show(ES.ToString());
                    }
                }
                else
                {
                    var query2 = db.Resource_Allocation.Where(x => x.resIdFK == IDs).ToList();
                    foreach (var item in query2)
                    {
                        db.Resource_Allocation.Remove(item);
                    }
                    for (int i = 0; i < skills.CheckedItems.Count; i++)
                    {
                        Resource_Allocation resource_Allocation = new Resource_Allocation();
                        resource_Allocation.resIdFK   = IDs;
                        resource_Allocation.skillIdFK = i + 1;
                        db.Resource_Allocation.Add(resource_Allocation);
                    }
                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Successful!");
                        this.Hide();
                        ResouceManagement resouceManagement = new ResouceManagement();
                        resouceManagement.Show();
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
            }
        }
예제 #3
0
        // public event EventHandler<EventArgs> DownUpdate;
        // public event EventHandler<EventArgs> DownOk;

        private void  载完成事件(object sender, AsyncCompletedEventArgs e)
        {
            new Task((() =>
            {
                try
                {
                    DownIofo.载状态 = false;
                    DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                    DownIofo.备注 = "下载任务结束";
                    if (e.Cancelled && !DownIofo.网络超时)
                    {
                        if (!DownIofo.播放状态 && DownIofo.是否是播放任务)
                        {
                            DownIofo.备注 = "播放窗口关闭";
                            DownIofo.载状态 = false;
                            载结束提醒(true, "下载任务结束", DownIofo);
                            return;
                        }
                        DownIofo.继承.待合并文件列表.Add(DownIofo.文件保存路径);
                        DownIofo.备注 = "用户取消,停止下载";
                        DownIofo.载状态 = false;
                        载结束提醒(true, "下载任务结束", DownIofo);
                    }
                    else if (!e.Cancelled && !bilibili.根据房间号获取房间信息.是否正在直播(DownIofo.房间_频道号, true))
                    {
                        DownIofo.继承.待合并文件列表.Add(DownIofo.文件保存路径);
                        DownIofo.载状态 = false;
                        DownIofo.备注 = "下载完成,直播间已关闭";
                        if (DownIofo.继承 == null)
                        {
                            DownIofo.继承.是否为继承对象 = false;
                        }
                        if (DownIofo.继承.是否为继承对象 && !DownIofo.是否是播放任务)
                        {
                            DownIofo.继承.合并后的文件路径 = 载完成合并FLV(DownIofo, true);
                            if (!string.IsNullOrEmpty(DownIofo.继承.合并后的文件路径))
                            {
                                DownIofo.文件保存路径 = DownIofo.继承.合并后的文件路径;
                            }
                        }
                        if (!DownIofo.是否是播放任务)
                        {
                            FlvMethod.转码(DownIofo.文件保存路径);
                        }
                        InfoLog.InfoPrintf(DownIofo.房间_频道号 + "房间:" + DownIofo.主播名称 + " 下播,录制完成", InfoLog.InfoClass.载必要提示);
                        foreach (var item in RoomInit.bilibili房间主表)
                        {
                            if (item.唯一码 == DownIofo.房间_频道号)
                            {
                                item.直播状态 = false;
                                break;
                            }
                        }
                        DownIofo.载状态 = false;
                        载结束提醒(true, "下载任务结束", DownIofo);
                        return;
                    }
                    else
                    {
                        if (bilibili.根据房间号获取房间信息.是否正在直播(DownIofo.房间_频道号, true) && DownIofo.是否保存)
                        {
                            DownIofo.网络超时 = true;
                            DownIofo.载状态 = false;
                            DownIofo.备注 = "下载流中断,检测到房间仍为开播状态,新建续下任务。";
                            DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                            switch (DownIofo.平台)
                            {
                            case "bilibili":
                                {
                                    if (!DownIofo.是否是播放任务)
                                    {
                                        DownIofo.继承.待合并文件列表.Add(DownIofo.文件保存路径);
                                        InfoLog.InfoPrintf($"{DownIofo.房间_频道号}:{DownIofo.主播名称}下载任务续下,历史文件加入待合并文件列表:{DownIofo.文件保存路径}", InfoLog.InfoClass.载必要提示);
                                    }
                                    DownIofo.载状态 = false;
                                    Downloader 重连下载对象 = Downloader.新建下载对象(
                                        DownIofo.平台,
                                        DownIofo.房间_频道号,
                                        bilibili.根据房间号获取房间信息.获取标题(DownIofo.房间_频道号),
                                        Guid.NewGuid().ToString(),
                                        bilibili.根据房间号获取房间信息.载地址(DownIofo.房间_频道号),
                                        "重连",
                                        DownIofo.是否保存,
                                        DownIofo.主播名称,
                                        true,
                                        DownIofo.文件保存路径,
                                        DownIofo
                                        );
                                    if (!重连下载对象.DownIofo.载状态)
                                    {
                                        try
                                        {
                                            重连下载对象.DownIofo.弹幕录制基准时间 = DownIofo.弹幕录制基准时间;
                                            重连下载对象.DownIofo.阿B直播流对象 = DownIofo.阿B直播流对象;
                                            重连下载对象.DownIofo.弹幕储存流 = DownIofo.弹幕储存流;
                                            重连下载对象.DownIofo.礼物储存流 = DownIofo.礼物储存流;
                                            重连下载对象.DownIofo.载状态 = false;
                                            重连下载对象.DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                            重连下载对象.DownIofo.备注 = "服务器主动断开连接,直播结束";
                                            foreach (var item in RoomInit.bilibili房间主表)
                                            {
                                                if (item.唯一码 == DownIofo.房间_频道号)
                                                {
                                                    item.直播状态 = false;
                                                    break;
                                                }
                                            }
                                            if (DownIofo.继承.是否为继承对象 && !DownIofo.是否是播放任务)
                                            {
                                                DownIofo.继承.合并后的文件路径 = 载完成合并FLV(DownIofo, true);
                                                if (!string.IsNullOrEmpty(DownIofo.继承.合并后的文件路径))
                                                {
                                                    DownIofo.文件保存路径 = DownIofo.继承.合并后的文件路径;
                                                }
                                            }
                                            if (!DownIofo.是否是播放任务)
                                            {
                                                FlvMethod.转码(DownIofo.文件保存路径);
                                            }
                                            DownIofo.备注 = "服务器主动断开连接,直播结束";
                                            重连下载对象.DownIofo.载状态 = false;
                                            重连下载对象.DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                            DownIofo.载状态 = false;
                                            DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                            载结束提醒(true, "下载任务结束", 重连下载对象.DownIofo);
                                        }
                                        catch (Exception) {}
                                        return;
                                    }
                                    new Task((() =>
                                    {
                                        while (true)
                                        {
                                            Thread.Sleep(10000);
                                            if (重连下载对象.DownIofo.已下载大小bit > 5000)
                                            {
                                                DownIofo.载状态 = false;
                                                DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                                载结束提醒(true, "下载任务结束", DownIofo);
                                                重连下载对象.DownIofo.备注 = "完成重连,正在续命..";
                                                //下载对象.DownIofo.下载状态 = true;
                                                return;
                                            }
                                            if (!bilibili.根据房间号获取房间信息.是否正在直播(DownIofo.房间_频道号, true))
                                            {
                                                重连下载对象.DownIofo.备注 = "停止直播";
                                                DownIofo.备注 = "直播停止,下载完成下载完成";
                                                重连下载对象.DownIofo.载状态 = false;
                                                重连下载对象.DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                                DownIofo.载状态 = false;
                                                DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                                重连下载对象.DownIofo.WC.CancelAsync();
                                                MMPU.DownList.Remove(重连下载对象);
                                                载结束提醒(true, "下载任务结束", DownIofo);
                                                载结束提醒(true, "下载任务结束", 重连下载对象.DownIofo);
                                                return;
                                            }
                                        }
                                    })).Start();
                                    DownIofo.载状态 = false;
                                    break;
                                }

                            default:
                                DownIofo.备注 = "不受支持的平台";
                                DownIofo.载状态 = false;
                                DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                                InfoLog.InfoPrintf("该房间的配置文件发现了与当前版本不支持的平台,请检查文件配置或者检查更新", InfoLog.InfoClass.系统错误信息);
                                //下载结束提醒(false);
                                return;
                            }
                        }
                        else
                        {
                            DownIofo.备注 = "直播停止,下载完成下载完成";
                            载结束提醒(true, "下载任务结束", DownIofo);
                            DownIofo.载状态 = false;
                            return;
                        }
                    }
                    DownIofo.载状态 = false;
                    DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                    DownIofo.备注 = "下载任务结束";
                }
                catch (Exception ES)
                {
                    InfoLog.InfoPrintf($"录制任务意外终止:\r\n{ES.ToString()}", InfoLog.InfoClass.系统错误信息);
                    DownIofo.载状态 = false;
                    DownIofo.备注 = "录制任务意外终止,已新建续命任务";
                    载结束提醒(true, "录制任务意外终止,已新建续命任务", DownIofo);
                    Downloader 载对象 = new Downloader();
                    try
                    {
                        DownIofo.载状态 = false;
                        载对象 = Downloader.新建下载对象(
                            DownIofo.平台,
                            DownIofo.房间_频道号,
                            bilibili.根据房间号获取房间信息.获取标题(DownIofo.房间_频道号),
                            Guid.NewGuid().ToString(),
                            bilibili.根据房间号获取房间信息.载地址(DownIofo.房间_频道号),
                            "前一个下载出现异常,新建下载",
                            DownIofo.是否保存,
                            DownIofo.主播名称,
                            false,
                            DownIofo.文件保存路径
                            );
                    }
                    catch (Exception)
                    {
                        try
                        {
                            载对象.DownIofo.备注 = "新建续下载对象出现异常,放弃新建任务";
                            载结束提醒(true, "下载任务结束", DownIofo);
                            载对象.DownIofo.载状态 = false;
                            载对象.DownIofo.结束时间 = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
                            载对象.DownIofo.WC.CancelAsync();
                            MMPU.DownList.Remove(载对象);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            })).Start();
        }
예제 #4
0
        protected void gvChildGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (ChildFlag)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    string errortbl = Session["Errortbl"].ToString();
                    com += Convert.ToInt32(e.Row.Cells[1].Text != "&nbsp;" ? e.Row.Cells[1].Text : e.Row.Cells[1].Text = "0");

                    if (e.Row.Cells[2].Text != "&nbsp;")
                    {
                        inc += Convert.ToInt32(e.Row.Cells[2].Text);
                    }
                    else
                    {
                        e.Row.Cells[2].Text = "0";
                    }
                    if (e.Row.Cells[3].Text != "&nbsp;")
                    {
                        inp += Convert.ToInt32(e.Row.Cells[3].Text);
                    }
                    else
                    {
                        e.Row.Cells[3].Text = "0";
                    }
                    if (e.Row.Cells[4].Text != "&nbsp;")
                    {
                        TS += Convert.ToInt32(e.Row.Cells[4].Text);
                    }
                    else
                    {
                        e.Row.Cells[4].Text = "0";
                    }
                    if (e.Row.Cells[5].Text != "&nbsp;")
                    {
                        ES += Convert.ToInt32(e.Row.Cells[5].Text);
                    }
                    else
                    {
                        e.Row.Cells[5].Text = "0";
                    }
                    if (e.Row.Cells[6].Text != "&nbsp;")
                    {
                        NS += Convert.ToInt32(e.Row.Cells[6].Text);
                    }
                    else
                    {
                        e.Row.Cells[6].Text = "0";
                    }
                    NoStatus       += Convert.ToInt32(e.Row.Cells[7].Text != "&nbsp;" ? e.Row.Cells[7].Text : e.Row.Cells[7].Text = "0");
                    No_OF_Works    += Convert.ToInt32(e.Row.Cells[8].Text);
                    AACost         += Convert.ToDecimal(e.Row.Cells[9].Text);
                    TSCost         += Convert.ToDecimal(e.Row.Cells[10].Text);
                    TotalProvision += Convert.ToDecimal(e.Row.Cells[11].Text);
                    TotalExp       += Convert.ToDecimal(e.Row.Cells[12].Text);
                }
                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    string errortbl = Session["Errortbl"].ToString();
                    e.Row.Cells[0].Text = "Total";


                    e.Row.Cells[1].Text  = com.ToString();
                    e.Row.Cells[2].Text  = inc.ToString();
                    e.Row.Cells[3].Text  = inp.ToString();
                    e.Row.Cells[4].Text  = TS.ToString();
                    e.Row.Cells[5].Text  = ES.ToString();
                    e.Row.Cells[6].Text  = NS.ToString();
                    e.Row.Cells[7].Text  = NoStatus.ToString();
                    e.Row.Cells[8].Text  = No_OF_Works.ToString();
                    e.Row.Cells[9].Text  = AACost.ToString();
                    e.Row.Cells[10].Text = TSCost.ToString();
                    e.Row.Cells[11].Text = TotalProvision.ToString();
                    e.Row.Cells[12].Text = TotalExp.ToString();
                }
            }
            else
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    string errortbl = Session["Errortbl"].ToString();
                    if (flag)
                    {
                        dr = Dumy_dt.NewRow();
                    }
                    flag = false;

                    dr[0] = HeadName;
                    if (e.Row.Cells[0].Text.Trim() == "Completed" || e.Row.Cells[0].Text.Trim() == "पूर्ण")
                    {
                        e.Row.Cells[0].Text = "पूर्ण";
                        arr[0] += Convert.ToDecimal(e.Row.Cells[1].Text);
                        dr[1]   = e.Row.Cells[1].Text;
                    }
                    else if (e.Row.Cells[0].Text.Trim() == "Incomplete" || e.Row.Cells[0].Text.Trim() == "अपूर्ण")
                    {
                        e.Row.Cells[0].Text = "अपूर्ण";
                        arr[1] += Convert.ToDecimal(e.Row.Cells[1].Text);
                        dr[2]   = e.Row.Cells[1].Text;
                    }
                    else if (e.Row.Cells[0].Text.Trim() == "Inprogress" || e.Row.Cells[0].Text.Trim() == "Processing" || e.Row.Cells[0].Text.Trim() == "Current" || e.Row.Cells[0].Text.Trim() == "चालू" || e.Row.Cells[0].Text.Trim() == "प्रगतीत")
                    {
                        e.Row.Cells[0].Text = "प्रगतीत";
                        arr[2] += Convert.ToDecimal(e.Row.Cells[1].Text);
                        dr[3]   = e.Row.Cells[1].Text;
                    }
                    else if (e.Row.Cells[0].Text.Trim() == "Tender Stage" || e.Row.Cells[0].Text.Trim() == "निविदा स्तर")
                    {
                        e.Row.Cells[0].Text = "निविदा स्तर";
                        arr[3] += Convert.ToDecimal(e.Row.Cells[1].Text);
                        dr[4]   = e.Row.Cells[1].Text;
                    }
                    else if (e.Row.Cells[0].Text.Trim() == "Estimated Stage" || e.Row.Cells[0].Text.Trim() == "अंदाजपत्रकिय स्थर" || e.Row.Cells[0].Text.Trim() == "अंदाजपत्रकिय स्तर")
                    {
                        e.Row.Cells[0].Text = "अंदाजपत्रकिय स्थर";
                        arr[4] += Convert.ToDecimal(e.Row.Cells[1].Text);
                        dr[5]   = e.Row.Cells[1].Text;
                    }
                    else if (e.Row.Cells[0].Text.Trim() == "Not Started" || e.Row.Cells[0].Text.Trim() == "सुरू करणे" || e.Row.Cells[0].Text.Trim() == "सुरु न झालेली")
                    {
                        e.Row.Cells[0].Text = "सुरु न झालेली";
                        arr[5] += Convert.ToDecimal(e.Row.Cells[1].Text);
                        dr[6]   = e.Row.Cells[1].Text;
                    }

                    else
                    {
                        e.Row.Cells[0].Text = "सध्यास्तिथी उपलब्ध नाही";
                        dr[7] = e.Row.Cells[1].Text;
                    }

                    //e.Row.Cells[0].BackColor = System.Drawing.Color.Red;
                    TotalWork      += Convert.ToDecimal(e.Row.Cells[1].Text);
                    AACost         += Convert.ToDecimal(e.Row.Cells[2].Text);
                    TSCost         += Convert.ToDecimal(e.Row.Cells[3].Text);
                    TotalProvision += Convert.ToDecimal(e.Row.Cells[4].Text);
                    TotalExp       += Convert.ToDecimal(e.Row.Cells[5].Text);
                }
                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    string errortbl = Session["Errortbl"].ToString();
                    dr[8]  = TotalWork.ToString();
                    dr[9]  = AACost.ToString();
                    dr[10] = TSCost.ToString();
                    dr[11] = TotalProvision.ToString();
                    dr[12] = TotalExp.ToString();
                    Dumy_dt.Rows.Add(dr);
                    flag = true;
                    e.Row.Cells[0].Text = "एकूण";
                    e.Row.Cells[1].Text = TotalWork.ToString();
                    e.Row.Cells[2].Text = AACost.ToString();
                    e.Row.Cells[3].Text = TSCost.ToString();
                    e.Row.Cells[4].Text = TotalProvision.ToString();
                    e.Row.Cells[5].Text = TotalExp.ToString();
                    arr[6] += AACost;
                    arr[7] += TSCost;
                    arr[8] += TotalProvision;
                    arr[9] += TotalExp;
                }
            }
        }
예제 #5
0
        // Вычисление срока наступления
        public void CalcES()
        {
            // Если не источник
            if (IsEndOf.Count != 0)
            {
                if (CanCalculateES())
                {
                    OperationLogger.AddMessage("ES" + Name + " = ");


                    // Вычисление первого значения
                    int Max = (int)IsEndOf[0].StartDot.ES + IsEndOf[0].Duration;



                    // Временные переменные используемые для составления описания (логов) вычислений
                    string FirstElemOperationLog = ((int)IsEndOf[0].StartDot.ES).ToString() + " + " + IsEndOf[0].Duration.ToString();
                    string CalcLog = "";

                    if (IsEndOf.Count > 1)
                    {
                        OperationLogger.AppendToLastMessage("max{");
                    }


                    OperationLogger.AppendToLastMessage("ES" + IsEndOf[0].StartDot.Name + " + C" + IsEndOf[0].StartDot.Name + Name);



                    for (int i = 1; i < IsEndOf.Count; i++)
                    {
                        // Вычисление возможного значения
                        int temp = (int)IsEndOf[i].StartDot.ES + IsEndOf[i].Duration;


                        // Формирование сообщения
                        OperationLogger.AppendToLastMessage("; ES" + IsEndOf[i].StartDot.Name + " + C" + IsEndOf[i].StartDot.Name + Name);

                        CalcLog += "; " + ((int)IsEndOf[i].StartDot.ES).ToString() + " + " + IsEndOf[i].Duration.ToString();


                        // Выбор максимума
                        if (Max < temp)
                        {
                            Max = temp;
                        }
                    }

                    // Запись значения
                    ES = Max;


                    // Окончание сообщения
                    if (IsEndOf.Count > 1)
                    {
                        OperationLogger.AppendToLastMessage("} = max{" + FirstElemOperationLog + CalcLog + "}");
                    }

                    OperationLogger.AppendToLastMessage(" = " + ES.ToString());
                }

                // Если источник, ES = 0
            }
            else
            {
                ES = 0;

                OperationLogger.AddMessage("ES" + Name + " = ");

                OperationLogger.AppendToLastMessage(ES.ToString());
            }
        }