Example #1
0
        private void GenerateQrCode(string guid)
        {
            string json = new JavaScriptSerializer().Serialize(new
            {
                QRTEXT = guid,
            });
            string url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + "/WCFServices/MATORIN.QUICK_API.svc/CreateQRCode";
            //"http://172.20.20.115/WCFServices/MATORIN.QUICK_API.svc/CreateQRCode";//
            //
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "POST";

            request.ContentType   = "application/json";
            request.ContentLength = json.Length;

            using (var writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(json);
            }

            HttpWebResponse response           = (HttpWebResponse)request.GetResponse();
            var             dataStream         = response.GetResponseStream();
            StreamReader    reader             = new StreamReader(dataStream);
            string          responseFromServer = reader.ReadToEnd();

            JavaScriptSerializer js = new JavaScriptSerializer();
            var obj        = js.Deserialize <dynamic>(responseFromServer);
            var ResultData = obj["ResultData"];
            var QR_CODE    = ResultData["QR_CODE_URL"];

            Mydb.ExecuteNoNQuery("Update_ROOM_QRCODE", new SqlParameter[] { new SqlParameter("@room_guid", guid), new SqlParameter("@QRCODE", QR_CODE) }, CommandType.StoredProcedure);
        }
Example #2
0
        public static string AddInfo(int McId, List <DOC_FOR_MC> dc)
        {
            foreach (DOC_FOR_MC item in dc)
            {
                if (item.KAT_ID != 0)
                {
                    int CounOfDoc = (int)Mydb.ExecuteScalar("select COUNT(*) from DOC_FOR_MC where D_URL=@url and MC_ID=@mc", new SqlParameter[] { new SqlParameter("@url", item.D_URL), new SqlParameter("@mc", McId) }, CommandType.Text);
                    if (CounOfDoc == 0)
                    {
                        // Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where MC_ID=@mc", new SqlParameter[] { new SqlParameter("@mc", McId) }, CommandType.Text);
                        Mydb.ExecuteNoNQuery("insert into  DOC_FOR_MC (D_NAME,D_URL,KAT_ID,MC_ID) values (@dnm,@durl,@kid,@mc)", new SqlParameter[] { new SqlParameter("@dnm", item.D_NAME), new SqlParameter("@durl", item.D_URL), new SqlParameter("@kid", item.KAT_ID), new SqlParameter("@mc", McId) }, CommandType.Text);
                    }
                }
                //else
                //{
                //    Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where MC_ID=@mc", new SqlParameter[] { new SqlParameter("@mc", McId) }, CommandType.Text);
                //}
            }


            //foreach (DOC_FOR_MC item in dcRemove)
            //{
            //if (item.D_NAME=="Udal")
            //{
            //    Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where D_URL=@d", new SqlParameter[] { new SqlParameter("@d", item.D_URL) }, CommandType.Text);
            //}

            //}


            return("");
        }
        public static string LoginIdentity(string Id_, string isTenant, string role)
        {
            string returnvalue = null;

            try
            {
                if (isTenant == "false")
                {
                    /*
                     * Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "2"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure);*/
                    if (role != "УК")
                    {
                        returnvalue = UK_Login(Id_);
                    }
                    else
                    {
                        int CountOfMailAsClient = Convert.ToInt32(Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "6"), new SqlParameter("@mail", Id_) }, CommandType.StoredProcedure));

                        if (CountOfMailAsClient == 0)
                        {
                            Mydb.ExecuteNoNQuery("InsertNewClient_T", new SqlParameter[] { new SqlParameter("@mail", Id_) }, CommandType.StoredProcedure);

                            returnvalue = UK_Login(Id_);
                        }
                        else
                        {
                            returnvalue = UK_Login(Id_);
                        }
                    }
                }
                else if (isTenant == "true")
                {
                    //Mydb.ExecuteAsJson("LoginSecond", new SqlParameter[] { new SqlParameter("@sc", Id_), new SqlParameter("@pass", pass) }, CommandType.StoredProcedure)
                    returnvalue = Mydb.ExecuteAsJson("TestDB.dbo.sp_QUICK_API_get_accounts_by_device1", new SqlParameter[] { new SqlParameter("@device_id", Id_) }, CommandType.StoredProcedure);
                }
            }
            catch (Exception ex)
            {
                returnvalue = "{\"result\" : \"ErrorIdendity\"}";
            }

            /*
             * return Redirect(AppConstants.AuthServer() + "/connect/endsession?id_token_hint=" + idToken + "&post_logout_redirect_uri=" + AppConstants.ClientServer() + "/signout-callback-oidc");
             */


            //HttpContext.Current.Response.Redirect("https://upravbot.ru/IDS4/Account/Logout?logoutId=CfDJ8JQq6V4gQ1xPva8MeQadqxUh3pMtraOr8jUvW3qBRzq9wjZC_7fNFZKIYrQJb94_dXsQJdLY64yybb8ZktHoTlmfzsLBfLLKRHIAuq7no_fY4fV35KwYxS6yGoQ10iGckHDmBjHS6pJcM8SwTA141e9htZFEwmiA1BQ9klespO6JcD4xZLTWbHbKm9N0juHicGdGySaC0TS5WQBsdJ3CxhDQeAt9lmcNZLTlv-2zOS8aX1bnW3p_UkLyOOszvEij3SsQSdcxo4GzSMW6UJ5ZhVBO9PizBVpxKTgKf-0ntb1_EMTxBC20xBY1h_foAP_vjsAyt2a8mEFSxRdZRcjiBIM");
            //HttpContext.Current.Response.Cookies.Remove("cookie");
            //HttpContext.Current.Response.Cookies["cookie"].Expires = DateTime.Now.AddDays(-1);
            //HttpContext.Current.GetOwinContext().Authentication.SignOut("Cookies");
            //HttpContext.Current.GetOwinContext().Authentication.SignOut("oidc");
            //HttpContext.Current.GetOwinContext().Authentication.SignOut();
            //  HttpContext.Current.GetOwinContext().Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType);
            // examplefunction();
            return(returnvalue);
        }
Example #4
0
        public static string MakeZakrit(int rid, string rst, string sm)
        {
            Mydb.ExecuteNoNQuery("update REQUEST set STATUS_ID=5 where REQUEST_ID=@rid", new SqlParameter[] { new SqlParameter("@rid", rid) }, CommandType.Text);

            Mydb.ExecuteNoNQuery("insert into REQUEST_STATUS_TEXT (RS_TEXT,RS_SMILE) values (@rst,@rsm)", new SqlParameter[] { new SqlParameter("@rst", rst), new SqlParameter("@rsm", sm) }, CommandType.Text);

            int LastId = (int)Mydb.ExecuteScalar(" select top 1 RST_ID from REQUEST_STATUS_TEXT order by RST_ID desc", new SqlParameter[] { }, CommandType.Text);

            Mydb.ExecuteNoNQuery("insert into REQUEST_STATUS_FILE (REQUEST_ID,FILE_ADRESS,RST_ID)values (@r_id,@fs,@rst)", new SqlParameter[] { new SqlParameter("@r_id", rid), new SqlParameter("@fs", "0"), new SqlParameter("@rst", LastId) }, CommandType.Text);
            return("{\"result\" : \"ok\"}");
        }
        public static string SendMail(string mailto, string subject, string body)
        {
            string returnvalue = null;

            try
            {
                Mydb.ExecuteNoNQuery("sp_Send_Mail_Upravbot", new SqlParameter[] { new SqlParameter("@mailto", mailto), new SqlParameter("@theme", subject), new SqlParameter("@body", body) }, CommandType.StoredProcedure);
                returnvalue = "";
            }
            catch (Exception)
            {
                throw;
            }
            return(returnvalue);
        }
Example #6
0
        public static string ChangePass_(int Id, string Pass)
        {
            Pass = GetMd5HashData(Pass);
            Mydb.ExecuteNoNQuery("update ACCOUNT set PASSWORD=@p where CLIENT_ID=@id and LOGIN is null", new SqlParameter[] { new SqlParameter("@p", Pass), new SqlParameter("@id", Id) }, CommandType.Text);
            int LogId = (int)Mydb.ExecuteScalar("select LOG_IN_ID from ACCOUNT where CLIENT_ID=@c", new SqlParameter[] { new SqlParameter("@c", Id) }, CommandType.Text);

            Mydb.ExecuteNoNQuery("update CLIENT set  GUID=NEWID() where CLIENT_ID=@Id", new SqlParameter[] { new SqlParameter("@Id", Id) }, CommandType.Text);
            Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                new SqlParameter("@EVENT_TYPE", "Восстановление пароля"),
                new SqlParameter("@EVENT_STATUS", "Систем"),
                new SqlParameter("@EVENT_ROLE", "Администратор"),
                new SqlParameter("@EVENT_MODULE", "Клиентское администрирование"),
                new SqlParameter("@EVENT_MESSAGE", "Пользователь  запросил (" + LogId + ") Восстановление пароля"),
                new SqlParameter("@EVENT_MAKER", LogId)
            }, CommandType.StoredProcedure);
            return("{\"result\" : \"1\"}");
        }
 public static string ControlAndSave(string mail, int TipOrg, string Pass)
 {
     try
     {
         int countOfmail = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT where E_MAIL =@mail", new SqlParameter[] { new SqlParameter("@mail", mail) }, CommandType.Text);
         if (countOfmail == 0)
         {
             Mydb.ExecuteNoNQuery("insert into CLIENT (ATTRIBUTE_ID,VERIFICATION_) values(@ID,@verf)", new SqlParameter[] { new SqlParameter("@ID", TipOrg), new SqlParameter("@verf", false) }, CommandType.Text);
             int LastClientId = (int)Mydb.ExecuteScalar("SELECT TOP 1 CLIENT_ID FROM CLIENT ORDER BY CLIENT_ID DESC", new SqlParameter[] { }, CommandType.Text);
             Mydb.ExecuteNoNQuery("insert into ACCOUNT(E_MAIL,PASSWORD,CLIENT_ID) values(@mail,@pass,@Cl_ID)", new SqlParameter[] { new SqlParameter("@mail", mail), new SqlParameter("@pass", GetMd5HashData(Pass)), new SqlParameter("@Cl_ID", LastClientId) }, CommandType.Text);
             string guid   = Mydb.ExecuteScalar("select GUID from CLIENT where CLIENT_ID=(select CLIENT_ID from ACCOUNT where E_MAIL=@EmailC)", new SqlParameter[] { new SqlParameter("@EmailC", mail) }, CommandType.Text).ToString();
             string CLient = Mydb.ExecuteScalar("select CLIENT_ID from ACCOUNT where E_MAIL=@mailC", new SqlParameter[] { new SqlParameter("@mailC", mail) }, CommandType.Text).ToString();
             string LogId  = Mydb.ExecuteScalar("select LOG_IN_ID from ACCOUNT where E_MAIL=@mailC", new SqlParameter[] { new SqlParameter("@mailC", mail) }, CommandType.Text).ToString();
             //string RolName = "Нечего";
             //string ModulName = "Нечего";
             //if (role == "4")
             //{
             //    ModulName = "Клиентское администрирование";
             //    RolName = "Администратор";
             //}
             //if (role == "3")
             //{
             //    ModulName = "Диспетчерская";
             //    RolName = "Диспетчер";
             //}
             Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                 new SqlParameter("@EVENT_TYPE", "Регистрация"),
                 new SqlParameter("@EVENT_STATUS", "Систем"),
                 new SqlParameter("@EVENT_ROLE", "Администратор"),
                 new SqlParameter("@EVENT_MODULE", "Клиентское администрирование"),
                 new SqlParameter("@EVENT_MESSAGE", "Зарегистрирован новый пользователь (email: " + mail + ")"),
                 new SqlParameter("@EVENT_MAKER", LogId)
             }, CommandType.StoredProcedure);
             return("{\"result\" : \"2\",\"guid\" : \"" + guid + "\",\"Id\" : \"" + CLient + "\",\"logId\":\"" + LogId + "\"}");
         }
         else
         {
             return("{\"result\" : \"1\"}");
         }
     }
     catch (Exception e)
     {
         return("{\" ERROR\" : \"" + e.Message.ToString() + "\"}");
     }
 }
Example #8
0
 public static string Change_Supplier_Offer(string guid)
 {
     Mydb.ExecuteNoNQuery("Change_Supplier_Offer", new SqlParameter[] { new SqlParameter("@guid", guid) }, CommandType.StoredProcedure);
     return("");
 }
Example #9
0
        public static string SaveRequest(string score, int indId, string Phone, List <ProductService_> prs, List <REQUEST_COMMENT> Cf, string RC, int ObjId, string comDate, string CFtime, string CTtime)
        {
            string result      = "";
            int    ObDispCount = (int)Mydb.ExecuteScalar("select COUNT(*) from DISP_OBJECT where OBJECT_ID=@o", new SqlParameter[] { new SqlParameter("@o", ObjId) }, CommandType.Text);

            // int ObDispCount = 1;
            if (ObDispCount != 0)
            {
                if (indId != 0)
                {
                    int RoomT = (int)Mydb.ExecuteScalar("select ROOM_TYPE_ID from ROOM where ROOM_ID=(select ROOM_ID from PER_SCORE where SCORE_ID =(select SCORE_ID from INDIVIDUAL_PERSCORE where INDIVIDUAL_ID=@indId))", new SqlParameter[] { new SqlParameter("@indId", indId) }, CommandType.Text);


                    Mydb.ExecuteNoNQuery("insert into REQUEST (INDIVIDUAL_ID,CR_DATE,STATUS_ID,ROOM_T,NUMBER,COMFORDATE,COM_TIME_FROM,COM_TIME_TO)values(@indId,GETDATE(),2,@roomT,@score,CAST(@Comdate as date),CAST(REPLACE(@CFtime,'-',':')as time(0) ),CAST(REPLACE(@CTtime,'-',':')as time(0)))", new SqlParameter[] {
                        new SqlParameter("@indId", indId),
                        new SqlParameter("@roomT", RoomT),
                        new SqlParameter("@score", score),
                        new SqlParameter("@Comdate", comDate),
                        new SqlParameter("@CFtime", CFtime),
                        new SqlParameter("@CTtime", CTtime)
                    }, CommandType.Text);
                }
                else
                {
                    string[] splited = Phone.Split('|');
                    Mydb.ExecuteNoNQuery("insert into IND_NAME (FIRST_NAME,PHONE) values(@f,@p)", new SqlParameter[] { new SqlParameter("@f", splited[1]), new SqlParameter("@p", splited[0]) }, CommandType.Text);

                    int LastIndId = (int)Mydb.ExecuteScalar("select top 1 INDIVIDUAL_ID from IND_NAME order by INDIVIDUAL_ID desc", new SqlParameter[] { }, CommandType.Text);

                    Mydb.ExecuteNoNQuery("insert into INDIVIDUAL_PERSCORE (INDIVIDUAL_ID,SCORE_ID) values(@i,@s)", new SqlParameter[] { new SqlParameter("@i", LastIndId), new SqlParameter("@s", score) }, CommandType.Text);

                    int RoomT = (int)Mydb.ExecuteScalar("select ROOM_TYPE_ID from ROOM where ROOM_ID=(select ROOM_ID from PER_SCORE where SCORE_ID =(select SCORE_ID from INDIVIDUAL_PERSCORE where INDIVIDUAL_ID=@indId))", new SqlParameter[] { new SqlParameter("@indId", LastIndId) }, CommandType.Text);

                    Mydb.ExecuteNoNQuery("insert into REQUEST (INDIVIDUAL_ID,CR_DATE,STATUS_ID,ROOM_T,NUMBER,COMFORDATE,COM_TIME_FROM,COM_TIME_TO)values(@indId,GETDATE(),2,@roomT,@score,CAST(@Comdate as date),CAST(REPLACE(@CFtime,'-',':')as time(0) ),CAST(REPLACE(@CTtime,'-',':')as time(0)))", new SqlParameter[] {
                        new SqlParameter("@indId", LastIndId),
                        new SqlParameter("@roomT", RoomT),
                        new SqlParameter("@score", score),
                        new SqlParameter("@Comdate", comDate),
                        new SqlParameter("@CFtime", CFtime),
                        new SqlParameter("@CTtime", CTtime)
                    }, CommandType.Text);
                }
                int LastReqId = (int)Mydb.ExecuteScalar("select top 1 REQUEST_ID from REQUEST order by REQUEST_ID desc", new SqlParameter[] { }, CommandType.Text);
                foreach (ProductService_ item in prs)
                {
                    Mydb.ExecuteNoNQuery("insert into REQUEST_SERVICE (REQUEST_ID,P_SERVICE_ID,QUANTITY,COST) values (@Rid,@PId,@Q,@C)", new SqlParameter[] {
                        new SqlParameter("@Rid", LastReqId),
                        new SqlParameter("@PId", item.SERVICE_ID),
                        new SqlParameter("@Q", item.QUANTITY),
                        new SqlParameter("@C", item.COST)
                    }, CommandType.Text);
                }
                Mydb.ExecuteNoNQuery("insert into REQUEST_COMMENT(REQUEST_COMMENT,REQUEST_ID) values(@RC,@Rid)", new SqlParameter[] {
                    new SqlParameter("@Rc", RC),
                    new SqlParameter("@Rid", LastReqId)
                    //,new SqlParameter("@Cf",Cf)
                }, CommandType.Text);
                foreach (REQUEST_COMMENT item in Cf)
                {
                    if (item.COMMENT_FILE != "0")
                    {
                        Mydb.ExecuteNoNQuery("insert into REQUEST_COMMENT (H_COMMNET_FILE,REQUEST_ID) values (@Cf,@Rid)", new SqlParameter[] { new SqlParameter("@Cf", item.COMMENT_FILE), new SqlParameter("@Rid", LastReqId) }, CommandType.Text);
                    }
                }
                //Mydb.ExecuteNoNQuery("update IND_NAME set PHONE=@p where INDIVIDUAL_ID=@i", new SqlParameter[] { new SqlParameter("@p", Phone),new SqlParameter("@i",indId) }, CommandType.Text);
                result = "{\"result\" : \"ok\"}";
            }
            else
            {
                result = "{\"result\" : \"no\"}";
            }
            return(result);
        }
Example #10
0
        public static string MakeClose(int rid)
        {
            Mydb.ExecuteNoNQuery("update REQUEST set STATUS_ID=4 where REQUEST_ID=@rid", new SqlParameter[] { new SqlParameter("@rid", rid) }, CommandType.Text);

            return("{\"result\" : \"ok\"}");
        }
Example #11
0
 public static string makeOplat(int rid, string OFDates, string oftimeS, string oftimeE)
 {
     Mydb.ExecuteNoNQuery("update REQUEST set OK_DATE=CAST(@okd as date),OK_TIME_S=CAST(REPLACE(@okts,'-',':') as time(0)),OK_TIME_E=CAST(REPLACE(@okte,'-',':') as time(0)), STATUS_ID=8 where REQUEST_ID=@rid", new SqlParameter[] { new SqlParameter("@okd", OFDates), new SqlParameter("@okts", oftimeS), new SqlParameter("@okte", oftimeE), new SqlParameter("@rid", rid) }, CommandType.Text);
     return("");
 }
Example #12
0
        public static string AddCounterValue(string type, int mid, string VALUE_, string cnum)
        {
            if (VALUE_.IndexOf(',') != -1)
            {
                VALUE_ = VALUE_.Replace(',', '.');
            }
            decimal _VALUE_ = decimal.Parse(VALUE_, CultureInfo.InvariantCulture);

            Mydb.ExecuteNoNQuery("AddCounterValue", new SqlParameter[] { new SqlParameter("@mid", mid), new SqlParameter("@TYPE", type), new SqlParameter("@VALUE_", VALUE_) }, CommandType.StoredProcedure);
            #region Old
            //if (type== "Газ")
            //{
            //    //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] {new SqlParameter("@VALUE_", VALUE_),new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //    if (count != 0)
            //    {
            //        Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //    }
            //    else
            //    {
            //        Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    }
            //}
            //if (type== "Теплоэнергия")
            //{

            //    //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //    if (count != 0)
            //    {
            //        Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //    }
            //    else
            //    {
            //        Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    }

            //}
            //if (type== "ХВС")
            //{

            //    //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //    if (count != 0)
            //    {
            //        Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //    }
            //    else
            //    {
            //        Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    }

            //}
            //if (type== "ГВС")
            //{

            //    //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //    if (count != 0)
            //    {
            //        Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //    }
            //    else
            //    {
            //        Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //    }

            //}
            //if (type!= "Газ" && type != "Теплоэнергия" && type != "ХВС" && type != "ГВС" )
            //{
            //    if (type.Contains("T1"))
            //    {
            //        int AmountT = (int)Mydb.ExecuteScalar("select AMUNT_TARIF from METERS where METERS_ID=@mid", new SqlParameter[] { new SqlParameter("@mid", mid) }, CommandType.Text);

            //        if (AmountT==1)
            //        {

            //            int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //                if (count != 0)
            //                {
            //                    Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //                }
            //            else
            //            {
            //                Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            }


            //        }
            //        if (AmountT == 2)
            //        {
            //            int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //            //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_2,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            if (count != 0)
            //            {
            //                Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //            }
            //            else
            //            {
            //                Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,VALUE_2,METERS_ID) values (GETDATE(),@VALUE_,0,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            }
            //        }
            //        if (AmountT == 3)
            //        {
            //            int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //            //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_2,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            if (count != 0)
            //            {
            //                Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_=@VALUE_ where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //            }
            //            else
            //            {
            //                Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,VALUE_2,VALUE_3,METERS_ID) values (GETDATE(),@VALUE_,0,0,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            }
            //        }
            //    }
            //    if (type.Contains("T2"))
            //    {
            //        int AmountT = (int)Mydb.ExecuteScalar("select AMUNT_TARIF from METERS where METERS_ID=@mid", new SqlParameter[] { new SqlParameter("@mid",mid) }, CommandType.Text);
            //        if (AmountT==2)
            //        {
            //            int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //            //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_2,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            if (count != 0)
            //            {
            //                Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_2=@VALUE_2 where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_2", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //            }
            //            else
            //            {
            //                Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,VALUE_2,METERS_ID) values (GETDATE(),0,@VALUE_2,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_2", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            }
            //        }
            //        if (AmountT==3)
            //        {
            //            int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //            //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_2,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            if (count != 0)
            //            {
            //                Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_2=@VALUE_2 where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_2", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //            }
            //            else
            //            {
            //                Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,VALUE_2,VALUE_3,METERS_ID) values (GETDATE(),0,@VALUE_2,0,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_2", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //            }
            //        }
            //    }
            //    if (type.Contains("T3"))
            //    {
            //        //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_3,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //        int count = (int)Mydb.ExecuteScalar("select COUNT(*) from METER_VALUE where DATE_= CONVERT(date, getdate())and METERS_ID=(select METERS_ID from METERS where METERS_NUMBER=@cnum)", new SqlParameter[] { new SqlParameter("@cnum", cnum) }, CommandType.Text);

            //        //Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_2,METERS_ID) values (GETDATE(),@VALUE_,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //        if (count != 0)
            //        {
            //            Mydb.ExecuteNoNQuery("update METER_VALUE set VALUE_3=@VALUE_3 where METERS_ID=@mid and DATE_= CONVERT(date, getdate())", new SqlParameter[] { new SqlParameter("@VALUE_3", VALUE_), new SqlParameter("@mid", mid) }, CommandType.Text);
            //        }
            //        else
            //        {
            //            Mydb.ExecuteNoNQuery("insert into METER_VALUE(DATE_,VALUE_,VALUE_2,VALUE_3,METERS_ID) values (GETDATE(),0,0,@VALUE_3,@METERS_ID)", new SqlParameter[] { new SqlParameter("@VALUE_3", VALUE_), new SqlParameter("@METERS_ID", mid) }, CommandType.Text);
            //        }
            //    }
            //}
            #endregion
            return("");
        }
        public static string LoginSystem(string email_, string pass_)
        {
            #region BadKod
            //if (!email_.Contains("Login_"))
            //{
            //    int Cpass_Mail = (int)Mydb.ExecuteScalar("select COUNT(PASSWORD ) FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);
            //    if (Cpass_Mail > 0)
            //    {
            //        string pass_mail = Mydb.ExecuteScalar("select PASSWORD FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
            //        bool verf = (bool)Mydb.ExecuteScalar("select VERIFICATION_ from CLIENT where CLIENT_ID=(select CLIENT_ID from ACCOUNT where E_MAIL=@mail)", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);

            //        if (verf == true)
            //        {
            //            pass_ = GetMd5HashData(pass_);
            //            if (pass_mail == pass_)
            //            {
            //                string Client_Id = Mydb.ExecuteScalar("select CLIENT_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();

            //                string loginId = Mydb.ExecuteScalar("select LOG_IN_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
            //                return "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\"}";
            //            }
            //            else
            //            {
            //                return "{\"result\" : \"2\"}";
            //            }
            //        }
            //        else
            //        {
            //            return "{\"result\" : \"3\"}";
            //        }
            //    }
            //    else
            //    {
            //        return "{\"result\" : \"2\"}";
            //    }

            //}
            //else
            //{
            //    int Count_DBPass = (int)Mydb.ExecuteScalar("select count(PASSWORD) from ACCOUNT where LOGIN = @lg", new SqlParameter[] { new SqlParameter("@lg", email_) }, CommandType.Text);
            //    if (Count_DBPass > 0)
            //    {
            //        string DBPass = Mydb.ExecuteScalar("select PASSWORD from ACCOUNT where LOGIN = @lg", new SqlParameter[] { new SqlParameter("@lg", email_) }, CommandType.Text).ToString();

            //        pass_ = GetMd5HashData(pass_);
            //        if (pass_ == DBPass)
            //        {
            //            int LogId = (int)Mydb.ExecuteScalar("select LOG_IN_ID, PASSWORD from ACCOUNT where LOGIN=@lg", new SqlParameter[] { new SqlParameter("@lg", email_) }, CommandType.Text);
            //            DataTable dt = Mydb.ExecuteReadertoDataTable("select * from ACCOUNT_ROLE where LOG_IN_ID=@lgId", new SqlParameter[] { new SqlParameter("@lgId", LogId) }, CommandType.Text);
            //            List<MR> mrs = new List<MR>();
            //            foreach (DataRow item in dt.Rows)
            //            {
            //                MR mr = new MR();
            //                mr.sm = Mydb.ExecuteScalar("select MODUL_ID from MODUL_ROLE where MR_ID=@mr", new SqlParameter[] { new SqlParameter("@mr", Convert.ToInt32(item["MR_ID"])) }, CommandType.Text).ToString();
            //                mr.sr = Mydb.ExecuteScalar("select ROLE_ID from MODUL_ROLE where MR_ID=@mr", new SqlParameter[] { new SqlParameter("@mr", Convert.ToInt32(item["MR_ID"])) }, CommandType.Text).ToString();
            //                mrs.Add(mr);
            //            }
            //            JavaScriptSerializer js = new JavaScriptSerializer();
            //            return js.Serialize(mrs);
            //        }
            //        else
            //        {
            //            return "{\"result\" : \"2\"}";
            //        }
            //    }
            //    else
            //    {
            //        return "{\"result\" : \"2\"}";
            //    }

            //}
            #endregion

            string returnvalue    = null;
            string SUPPLIER_EMAIL = email_;
            if (!email_.Contains("Login_"))
            {
                int Cpass_Mail = (int)Mydb.ExecuteScalar("select COUNT(PASSWORD ) FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);
                if (Cpass_Mail > 0)
                {
                    string pass_mail = Mydb.ExecuteScalar("select PASSWORD FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
                    bool   verf      = (bool)Mydb.ExecuteScalar("select VERIFICATION_ from CLIENT where CLIENT_ID=(select CLIENT_ID from ACCOUNT where E_MAIL=@mail)", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);
                    if (verf == true)
                    {
                        pass_ = GetMd5HashData(pass_);
                        if (pass_mail == pass_)
                        {
                            string Client_Id = Mydb.ExecuteScalar("select CLIENT_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();               //4

                            string loginId = Mydb.ExecuteScalar("select LOG_IN_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();                 //5
                            int    count   = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT_ROLE where LOG_IN_ID =@lg", new SqlParameter[] { new SqlParameter("@lg", Convert.ToInt32(loginId)) }, CommandType.Text); //2
                            if (count == 1)
                            {
                                string role      = Mydb.ExecuteScalar("select ROLE_ID from MODUL_ROLE where MR_ID=(select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Convert.ToInt32(loginId)) }, CommandType.Text).ToString();//3
                                string RolName   = "Нечего";
                                string ModulName = "Нечего";
                                if (role == "4")
                                {
                                    ModulName = "Клиентское администрирование";
                                    RolName   = "Администратор";
                                }
                                if (role == "3")
                                {
                                    ModulName = "Диспетчерская";
                                    RolName   = "Диспетчер";
                                }
                                if (role == "1")
                                {
                                    ModulName = "Личный кабинет";
                                    RolName   = "Управляющий";
                                }
                                Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                                    new SqlParameter("@EVENT_TYPE", "Вход"),
                                    new SqlParameter("@EVENT_STATUS", "Систем"),
                                    new SqlParameter("@EVENT_ROLE", RolName),
                                    new SqlParameter("@EVENT_MODULE", ModulName),
                                    new SqlParameter("@EVENT_MESSAGE", "Пользователь  вошел в систему"),
                                    new SqlParameter("@EVENT_MAKER", loginId)
                                }, CommandType.StoredProcedure);
                                returnvalue = "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\",\"RoleId\":\"" + role + "\"}";
                            }
                            if (count > 1)
                            {
                                DataTable         dt  = Mydb.ExecuteReadertoDataTable("select ROLE_ID from MODUL_ROLE where MR_ID in (select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Convert.ToInt32(loginId)) }, CommandType.Text);
                                List <LoginDatas> lds = new List <LoginDatas>();
                                foreach (DataRow item in dt.Rows)
                                {
                                    LoginDatas ld = new LoginDatas();
                                    ld.ROLE_ID = item["ROLE_ID"].ToString();
                                    ld.Id      = Client_Id;
                                    ld.LogId   = loginId;
                                    ld.result  = "5";
                                    lds.Add(ld);
                                }
                                JavaScriptSerializer js = new JavaScriptSerializer();
                                //returnvalue= "{\"result\" : \"5\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\",\"Roles\":\"" + js.Serialize(rls) + "\"}";
                                returnvalue = js.Serialize(lds);
                            }
                        }
                        else
                        {
                            returnvalue = "{\"result\" : \"2\"}";
                        }
                    }
                    else
                    {
                        returnvalue = "{\"result\" : \"3\"}";
                    }
                }
                else
                {
                    // returnvalue= "{\"result\" : \"2\"}";
                    string RESULT = Mydb.ExecuteScalar("CHECK_SUPPLIER", new SqlParameter[] { new SqlParameter("@email", email_), new SqlParameter("@pass", pass_) }, CommandType.StoredProcedure).ToString();
                    returnvalue = RESULT;
                }
            }
            else
            {
                int IdCount = (int)Mydb.ExecuteScalar("select Count(*) from ACCOUNT where [LOGIN]=@login", new SqlParameter[] { new SqlParameter("@login", email_) }, CommandType.Text);//Convert.ToInt32(email_);
                if (IdCount != 0)
                {
                    // email_ = email_.Substring(email_.LastIndexOf('_') + 1);
                    int Id           = (int)Mydb.ExecuteScalar("select LOG_IN_ID from ACCOUNT where [LOGIN]=@login", new SqlParameter[] { new SqlParameter("@login", email_) }, CommandType.Text);//Convert.ToInt32(email_);//5
                    int Count_DBPass = (int)Mydb.ExecuteScalar("select count(PASSWORD) from ACCOUNT where LOG_IN_ID=@id", new SqlParameter[] { new SqlParameter("@id", Id) }, CommandType.Text);
                    if (Count_DBPass > 0)
                    {
                        string DBPass = Mydb.ExecuteScalar("select PASSWORD from ACCOUNT where LOG_IN_ID = @lg", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text).ToString();
                        pass_ = GetMd5HashData(pass_);
                        if (pass_ == DBPass)
                        {
                            if (SUPPLIER_EMAIL != "Login_742")
                            {
                                string Client_Id = Mydb.ExecuteScalar("select CLIENT_ID FROM ACCOUNT WHERE LOG_IN_ID=@lg", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text).ToString();//1

                                //string loginId = Mydb.ExecuteScalar("select LOG_IN_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
                                int count = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT_ROLE where LOG_IN_ID =@lg", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text);//2
                                if (count == 1)
                                {
                                    string role      = Mydb.ExecuteScalar("select ROLE_ID from MODUL_ROLE where MR_ID=(select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text).ToString();//3
                                    string RolName   = "Нечего";
                                    string ModulName = "Нечего";
                                    if (role == "4")
                                    {
                                        ModulName = "Клиентское администрирование";
                                        RolName   = "Администратор";
                                    }
                                    if (role == "3")
                                    {
                                        ModulName = "Диспетчерская";
                                        RolName   = "Диспетчер";
                                    }
                                    if (role == "1")
                                    {
                                        ModulName = "Личный кабинет";
                                        RolName   = "Управляющий";
                                    }
                                    if (role == "15")
                                    {
                                        ModulName = "Диспетчерская";
                                        RolName   = "Диспетчер поставщика";
                                    }
                                    if (role == "17")
                                    {
                                        ModulName = "Диспетчерская";
                                        RolName   = "Супер Диспетчер";
                                    }

                                    if (role == "16")
                                    {
                                        ModulName = "Профиль Управляющего";
                                        RolName   = "Ответственный";
                                    }
                                    Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                                        new SqlParameter("@EVENT_TYPE", "Вход"),
                                        new SqlParameter("@EVENT_STATUS", "Систем"),
                                        new SqlParameter("@EVENT_ROLE", RolName),
                                        new SqlParameter("@EVENT_MODULE", ModulName),
                                        new SqlParameter("@EVENT_MESSAGE", "Пользователь вошел в систему"),
                                        new SqlParameter("@EVENT_MAKER", Id)
                                    }, CommandType.StoredProcedure);
                                    returnvalue = "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
                                }
                                if (count > 1)
                                {
                                    DataTable         dt  = Mydb.ExecuteReadertoDataTable("select ROLE_ID from MODUL_ROLE where MR_ID in (select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text);//3
                                    List <LoginDatas> lds = new List <LoginDatas>();
                                    foreach (DataRow item in dt.Rows)
                                    {
                                        LoginDatas ld = new LoginDatas();
                                        ld.ROLE_ID = item["ROLE_ID"].ToString();
                                        ld.Id      = Client_Id;
                                        ld.LogId   = Id.ToString();
                                        ld.result  = "5";
                                        lds.Add(ld);
                                    }
                                    JavaScriptSerializer js = new JavaScriptSerializer();
                                    //returnvalue= "{\"result\" : \"5\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\",\"Roles\":\"" + js.Serialize(rls) + "\"}";
                                    returnvalue = js.Serialize(lds);
                                    //List<Roles> rls = new List<Roles>();
                                    //foreach (DataRow item in dt.Rows)
                                    //{
                                    //    Roles rl = new Roles();
                                    //    rl.ROLE_ID = Convert.ToInt32(item["ROLE_ID"]);
                                    //    rls.Add(rl);
                                    //}
                                    //JavaScriptSerializer js = new JavaScriptSerializer();
                                    //returnvalue= "{\"result\" : \"5\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"Roles\":\"" + js.Serialize(rls) + "\"}";
                                }
                            }
                            else
                            {
                                string role      = "15";
                                string RolName   = "Нечего";
                                string ModulName = "Нечего";

                                if (role == "15")
                                {
                                    ModulName = "Диспетчер поставщика";
                                    RolName   = "Диспетчер поставщика";
                                }
                                Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                                    new SqlParameter("@EVENT_TYPE", "Вход"),
                                    new SqlParameter("@EVENT_STATUS", "Систем"),
                                    new SqlParameter("@EVENT_ROLE", RolName),
                                    new SqlParameter("@EVENT_MODULE", ModulName),
                                    new SqlParameter("@EVENT_MESSAGE", "Пользователь вошел в систему"),
                                    new SqlParameter("@EVENT_MAKER", Id)
                                }, CommandType.StoredProcedure);
                                returnvalue = "{\"result\" : \"1\",\"Id\" :\"742\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
                            }
                        }
                        else
                        {
                            returnvalue = "{\"result\" : \"2\"}";
                        }
                    }
                    else
                    {
                        returnvalue = "{\"result\" : \"2\"}";
                    }
                }
                else
                {
                    returnvalue = "{\"result\" : \"2\"}";
                }
            }
            return(returnvalue);
        }
        private static string UK_Login(string Id_)
        {
            int    Id          = 0;
            string returnvalue = "";

            if (Id_.Contains('@'))
            {
                Id = Convert.ToInt32(Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "5"), new SqlParameter("@mail", Id_) }, CommandType.StoredProcedure));
            }
            else
            {
                Id_ = Id_.Substring(Id_.IndexOf('_') + 1);
                Id  = Convert.ToInt32(Id_);
            }
            string Client_Id = Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@lg", Id), new SqlParameter("@procType", "1") }, CommandType.StoredProcedure).ToString();//1


            int count = (int)Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "2"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure);//2

            if (count == 1)
            {
                string role      = Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "3"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure).ToString();//3
                string RolName   = "Нечего";
                string ModulName = "Нечего";
                if (role == "4")
                {
                    ModulName = "Клиентское администрирование";
                    RolName   = "Администратор";
                }
                if (role == "3")
                {
                    ModulName = "Диспетчерская";
                    RolName   = "Диспетчер";
                }
                if (role == "1")
                {
                    ModulName = "Личный кабинет";
                    RolName   = "Управляющий";
                }
                if (role == "15")
                {
                    ModulName = "Диспетчерская";
                    RolName   = "Диспетчер поставщика";
                }
                if (role == "17")
                {
                    ModulName = "Диспетчерская";
                    RolName   = "Супер Диспетчер";
                }

                if (role == "16")
                {
                    ModulName = "Профиль Управляющего";
                    RolName   = "Ответственный";
                }
                Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                    new SqlParameter("@EVENT_TYPE", "Вход"),
                    new SqlParameter("@EVENT_STATUS", "Систем"),
                    new SqlParameter("@EVENT_ROLE", RolName),
                    new SqlParameter("@EVENT_MODULE", ModulName),
                    new SqlParameter("@EVENT_MESSAGE", "Пользователь вошел в систему"),
                    new SqlParameter("@EVENT_MAKER", Id)
                }, CommandType.StoredProcedure);
                returnvalue = "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
            }
            if (count > 1)
            {
                DataTable         dt  = Mydb.ExecuteReadertoDataTable("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "3"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure);//3
                List <LoginDatas> lds = new List <LoginDatas>();
                foreach (DataRow item in dt.Rows)
                {
                    LoginDatas ld = new LoginDatas();
                    ld.ROLE_ID = item["ROLE_ID"].ToString();
                    ld.Id      = Client_Id;
                    ld.LogId   = Id.ToString();
                    ld.result  = "5";
                    lds.Add(ld);
                }
                JavaScriptSerializer js = new JavaScriptSerializer();

                returnvalue = js.Serialize(lds);
            }
            return(returnvalue);
        }
Example #15
0
        public static void COMPARE_REQUESTS(bool is_Compare, string Request_as_JSON, int R_id_guid, int lg, string EVENT_MESSAGE, string path, string R_Services)
        {
            string R_id_guid2 = R_id_guid.ToString();
            int    REQUEST_ID = 0;

            if (int.TryParse(R_id_guid2, out REQUEST_ID))
            {
            }
            string EVENT_TYPE;
            string EVENT_STATUS = "Важное";
            //  string path = HttpContext.Current.Request.Url.AbsolutePath;

            string EVENT_ROLE = (path.IndexOf("Manager/") > -1) ? "Управляющий" : (path.IndexOf("Super_Disp/") > -1) ? "Супер Диспетчер" : (path.IndexOf("Responsible_Admin/") > -1) ? "Ответственный" : (path.IndexOf("Disp_Admin/") > -1) ? "Диспетчер" : "Диспетчер поставщика";

            string EVENT_MODULE = (path.IndexOf("Manager/") > -1) ? "Профиль Управляющего" : (path.IndexOf("Super_Disp/") > -1) ? "Диспетчерская" : (path.IndexOf("Responsible_Admin/") > -1) ? "Профиль Управляющего" : (path.IndexOf("Disp_Admin/") > -1) ? "Диспетчерская" : "Диспетчер поставщика";

            if (is_Compare == false)
            {
                if (REQUEST_ID != 0)
                {
                    EVENT_TYPE = "Создан";
                    ExecuteNoNQuery("[usp_ConstructorAPI_INSERT_LOG]", new SqlParameter[] {
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@EVENT_STATUS", EVENT_STATUS),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_MODULE", EVENT_MODULE),
                        new SqlParameter("@EVENT_MESSAGE", EVENT_MESSAGE),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@JSON_DATAS", Request_as_JSON)
                    }, CommandType.StoredProcedure);
                    if (Request_as_JSON != "4" && Request_as_JSON != "5")
                    {
                        Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewUkR"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);

                        Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewResp"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);

                        Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewIspol"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                    }
                }
                else
                {
                    Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewSuppR"), new SqlParameter("@rGuid", R_id_guid2), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                }
            }
            else
            {
                EVENT_TYPE = "Обновить";

                ExecuteNoNQuery("[usp_ConstructorAPI_INSERT_LOG]", new SqlParameter[] {
                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                    new SqlParameter("@EVENT_STATUS", EVENT_STATUS),
                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                    new SqlParameter("@EVENT_MODULE", EVENT_MODULE),
                    new SqlParameter("@EVENT_MESSAGE", EVENT_MESSAGE),
                    new SqlParameter("@EVENT_MAKER", lg),
                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                    new SqlParameter("@JSON_DATAS", Request_as_JSON)
                }, CommandType.StoredProcedure);

                dynamic Old_requests = JsonConvert.DeserializeObject(ExecuteAsJson("GETRequestForLOG", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID) }, CommandType.StoredProcedure));

                dynamic newRequest      = JsonConvert.DeserializeObject(Request_as_JSON);
                int     STATUS_ID       = (int)newRequest[0].STATUS_ID;
                string  TextForPlanDate = "";
                string  TextForPlanTime = "";
                //if (REQUEST_ID != 0)
                //{
                //    Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewStatus"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@NewStatusId", STATUS_ID) }, CommandType.StoredProcedure);
                //}
                //else
                //{
                //    Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewUkRStatus"), new SqlParameter("@rGuid", R_id_guid2), new SqlParameter("@NewStatusId", STATUS_ID) }, CommandType.StoredProcedure);
                //}
                string   Pdate     = newRequest[0].Pdate;
                string[] charArray = Pdate.Split('-');

                Pdate = charArray[2] + "." + charArray[1] + '.' + charArray[0];

                string PLAN_END_DATE = Old_requests[0].PLAN_END_DATE;


                PLAN_END_DATE = (PLAN_END_DATE.Length != 0) ? PLAN_END_DATE.Substring(0, 10) : "";

                if (Pdate != PLAN_END_DATE && PLAN_END_DATE.Length != 0)
                {
                    TextForPlanDate = ": планируемая дата изменена с «" + PLAN_END_DATE + "» на «" + Pdate + "»";
                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 1),
                        new SqlParameter("@PLAN_DATE_TEXT", TextForPlanDate)
                    }, CommandType.StoredProcedure);
                }
                else
                {
                    if (PLAN_END_DATE.Length == 0)
                    {
                        TextForPlanDate = ": Выбран планируемая дата на «" + Pdate + "»";
                        ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                            new SqlParameter("@REQUEST_ID", REQUEST_ID),
                            new SqlParameter("@EVENT_MAKER", lg),
                            new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                            new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                            new SqlParameter("@LOG_TYPE", 1),
                            new SqlParameter("@PLAN_DATE_TEXT", TextForPlanDate)
                        }, CommandType.StoredProcedure);
                    }
                }
                string Ptime         = newRequest[0].Ptime;
                string PLAN_END_TIME = Old_requests[0].PLAN_END_TIME;
                PLAN_END_TIME = (PLAN_END_TIME.Length != 0) ? PLAN_END_TIME.Substring(0, 5) : "";
                Ptime         = Ptime.Substring(0, 5);
                if (Ptime != PLAN_END_TIME && PLAN_END_TIME.Length != 0)
                {
                    TextForPlanTime = ": планируемое время изменено с «" + PLAN_END_TIME + "» на «" + Ptime + "»";

                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 1),
                        new SqlParameter("@PLAN_DATE_TEXT", TextForPlanTime)
                    }, CommandType.StoredProcedure);
                }
                else
                {
                    if (PLAN_END_TIME.Length == 0)
                    {
                        TextForPlanTime = ": Выбран планируемое время  на «" + Ptime + "»";

                        ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                            new SqlParameter("@REQUEST_ID", REQUEST_ID),
                            new SqlParameter("@EVENT_MAKER", lg),
                            new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                            new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                            new SqlParameter("@LOG_TYPE", 1),
                            new SqlParameter("@PLAN_DATE_TEXT", TextForPlanTime)
                        }, CommandType.StoredProcedure);
                    }
                }


                //  string TextForPerformer = "";
                string newspId = Convert.ToString(newRequest[0].spId);
                Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "IspolChange"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@IspolId", newspId), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                string OldSPECIALIS_ID = Convert.ToString(Old_requests[0].SPECIALIS_ID);
                if (newspId != OldSPECIALIS_ID)
                {
                    var new_spId = (newRequest[0].spId != null) ? Convert.ToInt32(newRequest[0].spId) : DBNull.Value;

                    var Old_SPECIALIS_ID = (Old_requests[0].SPECIALIS_ID != DBNull.Value) ? Convert.ToInt32(Old_requests[0].SPECIALIS_ID) : DBNull.Value;
                    // TextForPerformer = "исполнитель изменен с «" + Old_requests.SPECIALIS_ID + "» на «" + newRequest.spId + "»";
                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 2),
                        new SqlParameter("@OLD_ID", Old_SPECIALIS_ID),
                        new SqlParameter("@NEW_ID", new_spId)
                    }, CommandType.StoredProcedure);
                }

                //  string TextForResponsible = "";
                string newResp = Convert.ToString(newRequest[0].RESPONSIBLE_ID);
                Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "RespChange"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@RespId", newResp), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                string oldResp = Convert.ToString(Old_requests[0].RESPONSIBLE_ID);
                if (newResp != oldResp)
                {
                    //TextForResponsible = "ответственный по заявке изменен с «" + Old_requests.RESPONSIBLE_ID + "» на «" + newRequest.RESPONSIBLE_ID + "»";
                    var New_RESPONSIBLE_ID = (newRequest[0].RESPONSIBLE_ID != null) ? Convert.ToInt32(newRequest[0].RESPONSIBLE_ID) : DBNull.Value;
                    var Old_RESPONSIBLE_ID = (Old_requests[0].RESPONSIBLE_ID != DBNull.Value) ? Convert.ToInt32(Old_requests[0].RESPONSIBLE_ID) : DBNull.Value;

                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 3),
                        new SqlParameter("@OLD_ID", Old_RESPONSIBLE_ID),
                        new SqlParameter("@NEW_ID", New_RESPONSIBLE_ID)
                    }, CommandType.StoredProcedure);
                }

                dynamic New_prs = JsonConvert.DeserializeObject(R_Services);
                dynamic Old_prs = JsonConvert.DeserializeObject(ExecuteAsJson("GETREQUEST_SERVICES_FOR_LOG", new SqlParameter[] { new SqlParameter("@REQUEST_ID", REQUEST_ID) }, CommandType.StoredProcedure));

                //Если Добавлена услуга или Группа услуг или изиеннено

                for (int k = 0; k < New_prs.Count; k++)
                {
                    string New_Service_Guid = Convert.ToString(New_prs[k].SERVICE_GUID);
                    object New_ParentId     = ExecuteScalar("GetParentIdOfServices", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", New_Service_Guid) }, CommandType.StoredProcedure);
                    int    CountOf_Service  = (int)Mydb.ExecuteScalar("GetServiceCount", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID), new SqlParameter("@service_gud", New_Service_Guid) }, CommandType.StoredProcedure);
                    //  Если Добавлена услуга
                    if (New_ParentId != DBNull.Value)
                    {
                        if (CountOf_Service == 0)
                        {
                            string NEW_quantity2 = Convert.ToString(New_prs[k].QUANTITY);

                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),

                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 5),
                                new SqlParameter("@NEW_QUANTITY", NEW_quantity2),
                                new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                            }, CommandType.StoredProcedure);
                        }
                        //изменено данные старых услуг
                        else
                        {
                            dynamic old          = JsonConvert.DeserializeObject(Mydb.ExecuteAsJson("GetService_COST_QUANTITY", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", New_Service_Guid), new SqlParameter("@rid", REQUEST_ID) }, CommandType.StoredProcedure));
                            string  OLD_quantity = Convert.ToString(old[0].QUANTITY);
                            string  OLD_cost     = Convert.ToString(old[0].COST);

                            string NEW_COST = Convert.ToString(New_prs[k].COST);

                            string NEW_quantity = Convert.ToString(New_prs[k].QUANTITY);
                            NEW_quantity = (NEW_quantity.IndexOf('.') != -1) ? NEW_quantity.Replace(".", ",") : NEW_quantity + ",00";
                            if (OLD_cost != NEW_COST)
                            {
                                ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                    new SqlParameter("@EVENT_MAKER", lg),
                                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                    new SqlParameter("@LOG_TYPE", 4),
                                    new SqlParameter("@OLD_COST", (OLD_cost == "0.00")?"Договорная":OLD_cost),
                                    new SqlParameter("@NEW_COST", (NEW_COST == "0.00")?"Договорная":NEW_COST),
                                    new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                                }, CommandType.StoredProcedure);
                            }
                            if (OLD_quantity != NEW_quantity)
                            {
                                ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                    new SqlParameter("@EVENT_MAKER", lg),
                                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                    new SqlParameter("@LOG_TYPE", 4),
                                    new SqlParameter("@OLD_QUANTITY", OLD_quantity),
                                    new SqlParameter("@NEW_QUANTITY", NEW_quantity),
                                    new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                                }, CommandType.StoredProcedure);
                            }
                        }
                    }
                    // Если Добавлена Группа услуг
                    else
                    {
                        int Count_Grups = (int)Mydb.ExecuteScalar("GetServiceCount", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID), new SqlParameter("@Parent", "yes") }, CommandType.StoredProcedure);
                        if (Count_Grups == 0)
                        {
                            string NEW_quantity2 = Convert.ToString(New_prs[k].QUANTITY);

                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),
                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 5),
                                new SqlParameter("@NEW_QUANTITY", NEW_quantity2),
                                new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                            }, CommandType.StoredProcedure);
                        }
                        else
                        {
                            // если старый Группа услуг изменено на новый
                            string Old_Service_Guid = Mydb.ExecuteScalar("GetGrupOf_service_ofRequest", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID) }, CommandType.StoredProcedure).ToString();
                            if (Old_Service_Guid != New_Service_Guid)
                            {
                                ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                    new SqlParameter("@EVENT_MAKER", lg),
                                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                    new SqlParameter("@LOG_TYPE", 7),
                                    new SqlParameter("@Old_Service_guid", Old_Service_Guid),
                                    new SqlParameter("@New_Service_guid", New_Service_Guid)
                                }, CommandType.StoredProcedure);
                            }
                        }
                    }
                }

                //если Удалено услуги
                for (int i = 0; i < Old_prs.Count; i++)
                {
                    string Old_Service_Guid = Convert.ToString(Old_prs[i].SERVICE_GUID);
                    object Old_ParentId     = ExecuteScalar("GetParentIdOfServices", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", Old_Service_Guid) }, CommandType.StoredProcedure);
                    if (Old_ParentId != DBNull.Value)
                    {
                        bool hasService = false;

                        for (int k = 0; k < New_prs.Count; k++)
                        {
                            string New_Service_Guid = Convert.ToString(New_prs[k].SERVICE_GUID);
                            if (New_Service_Guid == Old_Service_Guid)
                            {
                                hasService = true;
                            }
                        }
                        if (hasService == false)
                        {
                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),
                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 6),
                                new SqlParameter("@OLD_QUANTITY", "0"),
                                new SqlParameter("@SERVICE_GUID", Old_Service_Guid)
                            }, CommandType.StoredProcedure);
                        }
                    }
                    else
                    {
                        bool IsDeletedOrNot = false;
                        for (int k = 0; k < New_prs.Count; k++)
                        {
                            string New_Service_Guid = Convert.ToString(New_prs[k].SERVICE_GUID);
                            object New_ParentId     = ExecuteScalar("GetParentIdOfServices", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", New_Service_Guid) }, CommandType.StoredProcedure);
                            if (New_ParentId != DBNull.Value)
                            {
                                IsDeletedOrNot = true;
                            }
                        }
                        if (IsDeletedOrNot == true)
                        {
                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),
                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 6),
                                new SqlParameter("@OLD_QUANTITY", "0"),
                                new SqlParameter("@SERVICE_GUID", Old_Service_Guid)
                            }, CommandType.StoredProcedure);
                        }
                    }
                }
            }
        }
Example #16
0
 public static string DelDoc(string url)
 {
     Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where D_URL=@url", new SqlParameter[] { new SqlParameter("@url", url) }, CommandType.Text);
     return("");
 }