Ejemplo n.º 1
0
        public bool PeriodAutoclavStart()
        {
            try
            {
                string timeStartAutoclav = PublicMehotd.time_php();

                //MessageBox.Show((Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString() + " X " + timeStartAutoclav);

                Varibale.Status_Autoclav[Dev_no] = (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.autoclav.ToString());

                cmd.Parameters.AddWithValue("intTimestart", (Convert.ToInt32(timeStartAutoclav) - Varibale.Timer_Autoclav[Dev_no]).ToString());

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime(-1 * Varibale.Timer_Autoclav[Dev_no]));

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cmd.Parameters.AddWithValue("time_st", Varibale.Data_Timer_Max[Dev_no].ToString());

                cmd.Parameters.AddWithValue("temp_low_st", Varibale.Data_Temp_Min[Dev_no]);

                cmd.Parameters.AddWithValue("temp_high_st", Varibale.Data_Temp_Max[Dev_no]);

                cmd.Parameters.AddWithValue("pres_st", Varibale.Data_Pres_Min[Dev_no]);

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();

                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-start-autoclav");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void NewLogInsertToDatabase()
        {
            try
            {
                SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Log_New", cn);

                cmd.Parameters.AddWithValue("dev_no", DeviceNumber);
                cmd.Parameters.AddWithValue("kind", Kind.ToString());
                cmd.Parameters.AddWithValue("comment", classEnumLog.ShowError(Type));
                cmd.Parameters.AddWithValue("level", Level.ToString());
                cmd.Parameters.AddWithValue("intTime", (Convert.ToInt32(PublicMehotd.time_php()) + Sec));
                cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime(Sec));
                cmd.Parameters.AddWithValue("datetimep", PublicMehotd.retStringShowDatetime());
                cmd.Parameters.AddWithValue("value", Val);
                cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();
            }
            catch (Exception ex)
            {
                //Enum.ClassEnumError.ShowErrorInMessageBox(EnumError.insertNewLogProbel);
                log_system.saveLogSystem(ex, "log_manager insert");
            }
        }
Ejemplo n.º 3
0
        public static bool InsertToDatabase(int devicenumber, Enum.EnumTypeData type, Enum.EnumKindDevice kind, double value)
        {
            try
            {
                Boolean check = true;

                if (check)
                {
                    SqlConnection cn = ConnectToDatabase.NewConnectToDatabase();

                    SqlCommand cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_Data_new", cn);

                    cmd.Parameters.AddWithValue("dev_no", devicenumber);
                    cmd.Parameters.AddWithValue("type", type.ToString());
                    cmd.Parameters.AddWithValue("kind", kind.ToString());
                    cmd.Parameters.AddWithValue("value", value);
                    cmd.Parameters.AddWithValue("intTime", PublicMehotd.time_php());
                    cmd.Parameters.AddWithValue("datep", PublicMehotd.RetStringPersianCalender());
                    cmd.Parameters.AddWithValue("timep", PublicMehotd.RetStringLocalTime());
                    cmd.Parameters.AddWithValue("yearp", PublicMehotd.retStringYearPersian());
                    cmd.Parameters.AddWithValue("monthp", PublicMehotd.retStringMonthPersian());
                    cmd.Parameters.AddWithValue("dayp", PublicMehotd.retStringDayPersian());
                    cmd.Parameters.AddWithValue("datetimep", Convert.ToDouble(PublicMehotd.retStringShowDatetime()));

                    cn.Open();
                    object obj = cmd.ExecuteScalar();
                    cn.Close();

                    if (Autoclav.sendServer_count == Varibale.save_count_autoclav_server)
                    {
                        Autoclav.sendServer_count = 0;
                    }
                    else
                    {
                        Autoclav.sendServer_count++;
                    }


                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "autoclav-insert database");
                //Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewDatalogforautoclav);
                return(false);
            }
        }
Ejemplo n.º 4
0
        public bool PeriodBakingStart()
        {
            try
            {
                string timeStartBaking = PublicMehotd.time_php();

                Varibale.Status_Baking[Dev_no] = timeStartBaking.ToString();

                SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
                SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(System.Data.CommandType.StoredProcedure, "Insert_start_New_Period", cn);

                cmd.Parameters.AddWithValue("dev_no", Dev_no);

                cmd.Parameters.AddWithValue("status", Enum.EnumStatusPeriod.start.ToString());

                cmd.Parameters.AddWithValue("kind", Enum.EnumKindDevice.baking.ToString());

                cmd.Parameters.AddWithValue("intTimestart", timeStartBaking);

                cmd.Parameters.AddWithValue("intTimeend", 0);

                cmd.Parameters.AddWithValue("timestart", PublicMehotd.RetStringLocalTime());

                cmd.Parameters.AddWithValue("timeend", "00:00:00");

                cmd.Parameters.AddWithValue("date", PublicMehotd.RetStringPersianCalender());

                cmd.Parameters.AddWithValue("year", PublicMehotd.retStringYearPersian());

                cmd.Parameters.AddWithValue("month", PublicMehotd.retStringMonthPersian());

                cmd.Parameters.AddWithValue("day", PublicMehotd.retStringDayPersian());

                cmd.Parameters.AddWithValue("intTimezero", "0");

                cmd.Parameters.AddWithValue("timezero", "00:00:00");

                cn.Open();
                object obj = cmd.ExecuteScalar();
                cn.Close();



                return(true);
            }
            catch (Exception ex)
            {
                log_system.saveLogSystem(ex, "period-baking-start");
                Enum.ClassEnumError.ShowErrorInMessageBox(Enum.EnumError.insertnewstartautoclavinsertdatabaseerror);
                return(false);
            }
        }
Ejemplo n.º 5
0
        public static void saveLogMsg(string msg)
        {
            string filepath = @"c:\log_monitoring\";
            string filename = PublicMehotd.RetStringPersianCalenderwithDash() + "-" + DateTime.Now.Hour.ToString("00") + ".txt";

            checkFileAndFolder(filename);

            using (System.IO.StreamWriter file =
                       File.AppendText(filepath + filename))
            {
                file.WriteLine("\n msg = " + msg);
                file.WriteLine("\n datep = " + PublicMehotd.RetStringPersianCalender());
                file.WriteLine("\n timep = " + PublicMehotd.RetStringLocalTime());
            }
        }
Ejemplo n.º 6
0
        private static void newRecord(int num, Int64 number)
        {
            zarinReport.closeAllRcord(num);

            string type = "";

            if (num == 1 || num == 2)
            {
                type = "ghabl";
            }
            else
            {
                type = "bad";
            }

            string sql = "insert into zarin_report_counter" +
                         " (status , intTimeStart , intTimeEnd, timeStart, timeEnd , datep  , yearp , monthp , dayp , number , zarin_product , brand , vazn , baste_bandi , darb , counter_num )" +
                         " values " +
                         " ('counts' , '" +
                         PublicMehotd.time_php() + "' , '0' , '" +
                         PublicMehotd.RetStringLocalTime() + "' , '00:00:00' , '" +
                         PublicMehotd.RetStringPersianCalender() + "' , '" +
                         PublicMehotd.retStringYearPersian() + "' , '" +
                         PublicMehotd.retStringMonthPersian() + "' , '" +
                         PublicMehotd.retStringDayPersian() + "' , '" +
                         number.ToString() + "' , '" +
                         ClassEnumProduct.getProductZarinNumber(Convert.ToInt64(Varibale.zarin["zarin_product_" + type]))
                         + "' , '" +
                         Varibale.zarin["brand_" + type]
                         + "' , '" +
                         Varibale.zarin["vazn_" + type]
                         + "' ,  '" +
                         Varibale.zarin["baste_bandi_" + type]
                         + "' , '" +
                         Varibale.zarin["darb_" + type]
                         + "' , '" +
                         num.ToString()
                         + "')";

            SqlConnection cn  = ConnectToDatabase.NewConnectToDatabase();
            SqlCommand    cmd = ConnectToDatabase.NewSqlCommand(CommandType.Text, sql, cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
        }